docstr: 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
docstr_tok: ["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"]
code: 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"] = th.tensor(pos).float()
      g.ndata["attr"] = th.tensor(
          self.node_attr[self.n_cumsum[idx] : self.n_cumsum[idx + 1]]
      ).float()
      g.edata["edge_attr"] = th.tensor(
          self.edge_attr[self.ne_cumsum[idx] : self.ne_cumsum[idx + 1]]
      ).float()
  
      label = th.tensor(self.targets[idx][self.label_keys]).float()
  
      n_nodes = g.num_nodes()
      row = th.arange(n_nodes)
      col = th.arange(n_nodes)
  
      row = row.view(-1, 1).repeat(1, n_nodes).view(-1)
      col = col.repeat(n_nodes)
  
      src = g.edges()[0]
      dst = g.edges()[1]
  
      idx = src * n_nodes + dst
      size = list(g.edata["edge_attr"].size())
      size[0] = n_nodes * n_nodes
      edge_attr = g.edata["edge_attr"].new_zeros(size)
  
      edge_attr[idx] = g.edata["edge_attr"]
  
      pos = g.ndata["pos"]
      dist = th.norm(pos[col] - pos[row], p=2, dim=-1).view(-1, 1)
  
      new_edge_attr = th.cat(
          [edge_attr, dist.type_as(edge_attr)], dim=-1
      )
  
      graph = dgl.graph((row, col))
      graph.ndata["attr"] = g.ndata["attr"]
      graph.edata["edge_attr"] = new_edge_attr
      graph = graph.remove_self_loop()
  
      return graph, label
  
file_path: dgl/examples/pytorch/infograph/semisupervised.py
imports: import argparse
  import dgl
  import numpy
  import torch
  import torch.nn.functional
  from dgl.data import QM9EdgeDataset
  from dgl.data.utils import Subset
  from dgl.dataloading import GraphDataLoader
  from model import InfoGraphS
label_desc: Use image node_id 1 for calling the DenseQM9EdgeDataset obj's underlying member method code with example usage: obj.__getitem__(idx) and returns: graph,  label