<｜begin▁of▁sentence｜>### Instruction:
Given a graph with vertices and edges that have attributes, can you demonstrate how to create a subclass of AttributeCollectorBase in igraph to collect and retrieve attributed data for vertices and edges?
### Response:
import igraph as ig

# Create a graph and add some attributes
g = ig.Graph(edges=[(0, 1), (1, 2), (2, 3)])
g.vs['label'] = ['v0', 'v1', 'v2', 'v3']
g.es['weight'] = [5, 3, 1]

# Define a collector class inheriting from AttributeCollectorBase
class MyAttributeCollector(ig.AttributeCollectorBase):
    def __init__(self, seq):
        super().__init__(seq, {'custom': 'unknown'})
        self._names = ('label', 'custom')

    def __getitem__(self, index):
        if self._data is not None:
            attrs = self._map_attrs(self._seq[index].attributes())
            attrs.update((name, self._data.get(name, 'none')) for name in self._names)
            return attrs

# Collect vertex attributes
vertex_collector = MyAttributeCollector(g.vs)
print(vertex_collector[1])

# Collect edge attributes
edge_collector = MyAttributeCollector(g.es)
print(edge_collector[2])
<|EOT|>
