# Buggy code
def __init__(self, graph_list, node_attrs, edge_attrs):
    # create batched graph index
    batched_index = gi.disjoint_union([g._graph for g in graph_list])
    # create batched node and edge frames
    # NOTE: following code will materialize the columns of the input graphs.
    cols = {
        key: F.cat(
            [gr._node_frame[key] for gr in graph_list if gr.number_of_nodes() > 0],
            dim=0,
        )
        for key in node_attrs
    }
    batched_node_frame = FrameRef(Frame(cols))

    cols = {
        key: F.cat(
            [gr._edge_frame[key] for gr in graph_list if gr.number_of_edges() > 0],
            dim=0,
        )
        for key in edge_attrs
    }
    batched_edge_frame = FrameRef(Frame(cols))

    super(BatchedDGLGraph, self).__init__(
        graph_data=batched_index,
        node_frame=batched_node_frame,
        edge_frame=batched_edge_frame,
    )

    # extra members
    self._batch_size = 0
    self._batch_num_nodes = []
    self._batch_num_edges = []
    for gr in graph_list:
        if isinstance(gr, BatchedDGLGraph):
            # handle the input is again a batched graph.
            self._batch_size += gr._batch_size
            self._batch_num_nodes += gr._batch_num_nodes
            self._batch_num_edges += gr._batch_num_edges
        else:
            self._batch_size += 1
            self._batch_num_nodes.append(gr.number_of_nodes())
            self._batch_num_edges.append(gr.number_of_edges())


# Traceback (dgl._ffi.base.DGLError)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/zy1404/repos/dgl/python/dgl/view.py", line 61, in __setitem__
self._graph.set_n_repr({key : val}, self._nodes)
File "/home/zy1404/repos/dgl/python/dgl/graph.py", line 821, in set_n_repr
self._node_frame[key] = val
File "/home/zy1404/repos/dgl/python/dgl/frame.py", line 618, in __setitem__
self.update_column(key, val, inplace=False)
File "/home/zy1404/repos/dgl/python/dgl/frame.py", line 647, in update_column
self._frame[name] = col
File "/home/zy1404/repos/dgl/python/dgl/frame.py", line 291, in __setitem__
self.update_column(name, data)
File "/home/zy1404/repos/dgl/python/dgl/frame.py", line 364, in update_column
(self.num_rows, len(col)))
dgl._ffi.base.DGLError: Expected data to have 0 rows, got 7.

# Fixed code
def __init__(self, graph_list, node_attrs, edge_attrs):
    # create batched graph index
    batched_index = gi.disjoint_union([g._graph for g in graph_list])
    # create batched node and edge frames
    if len(node_attrs) == 0:
        batched_node_frame = FrameRef(Frame(num_rows=batched_index.number_of_nodes()))
    else:
        # NOTE: following code will materialize the columns of the input graphs.
        cols = {
            key: F.cat(
                [gr._node_frame[key] for gr in graph_list if gr.number_of_nodes() > 0],
                dim=0,
            )
            for key in node_attrs
        }
        batched_node_frame = FrameRef(Frame(cols))

    if len(edge_attrs) == 0:
        batched_edge_frame = FrameRef(Frame(num_rows=batched_index.number_of_edges()))
    else:
        cols = {
            key: F.cat(
                [gr._edge_frame[key] for gr in graph_list if gr.number_of_edges() > 0],
                dim=0,
            )
            for key in edge_attrs
        }
        batched_edge_frame = FrameRef(Frame(cols))

    super(BatchedDGLGraph, self).__init__(
        graph_data=batched_index,
        node_frame=batched_node_frame,
        edge_frame=batched_edge_frame,
    )

    # extra members
    self._batch_size = 0
    self._batch_num_nodes = []
    self._batch_num_edges = []
    for gr in graph_list:
        if isinstance(gr, BatchedDGLGraph):
            # handle the input is again a batched graph.
            self._batch_size += gr._batch_size
            self._batch_num_nodes += gr._batch_num_nodes
            self._batch_num_edges += gr._batch_num_edges
        else:
            self._batch_size += 1
            self._batch_num_nodes.append(gr.number_of_nodes())
            self._batch_num_edges.append(gr.number_of_edges())