code: def __getitem__(self, idx):
      smiles = self.data[idx]
      mol_tree = DGLMolTree(smiles)
      mol_tree.recover()
      mol_tree.assemble()
  
      wid = _set_node_id(mol_tree, self.vocab)
  
      # prebuild the molecule graph
      mol_graph, atom_x_enc, bond_x_enc = mol2dgl_enc(mol_tree.smiles)
  
      result = {
          "mol_tree": mol_tree,
          "mol_graph": mol_graph,
          "atom_x_enc": atom_x_enc,
          "bond_x_enc": bond_x_enc,
          "wid": wid,
      }
  
      if not self.training:
          return result
  
      # prebuild the candidate graph list
      cands = []
      for node_id, node in mol_tree.nodes_dict.items():
          # fill in ground truth
          if node["label"] not in node["cands"]:
              node["cands"].append(node["label"])
              node["cand_mols"].append(node["label_mol"])
  
          if node["is_leaf"] or len(node["cands"]) == 1:
              continue
          cands.extend(
              [(cand, mol_tree, node_id) for cand in node["cand_mols"]]
          )
      if len(cands) > 0:
          (
              cand_graphs,
              atom_x_dec,
              bond_x_dec,
              tree_mess_src_e,
              tree_mess_tgt_e,
              tree_mess_tgt_n,
          ) = mol2dgl_dec(cands)
      else:
          cand_graphs = []
          atom_x_dec = torch.zeros(0, ATOM_FDIM_DEC)
          bond_x_dec = torch.zeros(0, BOND_FDIM_DEC)
          tree_mess_src_e = torch.zeros(0, 2).long()
          tree_mess_tgt_e = torch.zeros(0, 2).long()
          tree_mess_tgt_n = torch.zeros(0).long()
  
      # prebuild the stereoisomers
      cands = mol_tree.stereo_cands
      if len(cands) > 1:
          if mol_tree.smiles3D not in cands:
              cands.append(mol_tree.smiles3D)
  
          stereo_graphs = [mol2dgl_enc(c) for c in cands]
          (
              stereo_cand_graphs,
              stereo_atom_x_enc,
              stereo_bond_x_enc,
          ) = zip(*stereo_graphs)
          stereo_atom_x_enc = torch.cat(stereo_atom_x_enc)
          stereo_bond_x_enc = torch.cat(stereo_bond_x_enc)
          stereo_cand_label = [
              (cands.index(mol_tree.smiles3D), len(cands))
          ]
      else:
          stereo_cand_graphs = []
          stereo_atom_x_enc = torch.zeros(0, atom_x_enc.shape[1])
          stereo_bond_x_enc = torch.zeros(0, bond_x_enc.shape[1])
          stereo_cand_label = []
  
      result.update(
          {
              "cand_graphs": cand_graphs,
              "atom_x_dec": atom_x_dec,
              "bond_x_dec": bond_x_dec,
              "tree_mess_src_e": tree_mess_src_e,
              "tree_mess_tgt_e": tree_mess_tgt_e,
              "tree_mess_tgt_n": tree_mess_tgt_n,
              "stereo_cand_graphs": stereo_cand_graphs,
              "stereo_atom_x_enc": stereo_atom_x_enc,
              "stereo_bond_x_enc": stereo_bond_x_enc,
              "stereo_cand_label": stereo_cand_label,
          }
      )
  
      return result
  
file_path: dgl/examples/pytorch/jtnn/jtnn/datautils.py
imports: import dgl
  import torch
  from dgl.data.utils import _get_dgl_url, download, extract_archive, get_download_dir
  from torch.utils.data import Dataset
  from .jtmpn import ATOM_FDIM, BOND_FDIM, mol2dgl_single
  from .mol_tree import Vocab
  from .mol_tree_nx import DGLMolTree
  from .mpn import mol2dgl_single
label_desc: Use image node_id 3 for calling the JTNNDataset obj's underlying member method code with example usage: obj.__getitem__(idx) and returns: result, result