def __getitem__(self, idx):
        r"""Get graph and label by index

        Parameters
        ----------
        idx : int
            Item index

        Returns
        -------
        dgl.DGLGraph
           The graph contains:

           - ``ndata['pos']``: the coordinates of each atom
           - ``ndata['attr']``: the features of each atom
           - ``edata['edge_attr']``: the features of each bond

        Tensor
            Property values of molecular graphs
        """

        pos = self.node_pos[self.n_cumsum[idx] : self.n_cumsum[idx + 1]]
        src = self.src[self.ne_cumsum[idx] : self.ne_cumsum[idx + 1]]
        dst = self.dst[self.ne_cumsum[idx] : self.ne_cumsum[idx + 1]]

        g = dgl_graph((src, dst))

        g.ndata["pos"] = F.tensor(pos, dtype=F.data_type_dict["float32"])
        g.ndata["attr"] = F.tensor(
            self.node_attr[self.n_cumsum[idx] : self.n_cumsum[idx + 1]],
            dtype=F.data_type_dict["float32"],
        )
        g.edata["edge_attr"] = F.tensor(
            self.edge_attr[self.ne_cumsum[idx] : self.ne_cumsum[idx + 1]],
            dtype=F.data_type_dict["float32"],
        )

        label = F.tensor(
            self.targets[idx][self.label_keys],
            dtype=F.data_type_dict["float32"],
        )

        if self._transform is not None:
            g = self._transform(g)

        return g, label
Get graph and label by index

        Parameters
        ----------
        idx : int
            Item index

        Returns
        -------
        dgl.DGLGraph
           The graph contains:

           - ``ndata['pos']``: the coordinates of each atom
           - ``ndata['attr']``: the features of each atom
           - ``edata['edge_attr']``: the features of each bond

        Tensor
            Property values of molecular graphs
        
python/dgl/data/qm9_edge.py