code: def __call__(self, examples):
      # get list of trees
      mol_trees = _unpack_field(examples, "mol_tree")
      wid = _unpack_field(examples, "wid")
      for _wid, mol_tree in zip(wid, mol_trees):
          mol_tree.graph.ndata["wid"] = torch.LongTensor(_wid)
  
      # TODO: either support pickling or get around ctypes pointers using scipy
      # batch molecule graphs
      mol_graphs = _unpack_field(examples, "mol_graph")
      atom_x = torch.cat(_unpack_field(examples, "atom_x_enc"))
      bond_x = torch.cat(_unpack_field(examples, "bond_x_enc"))
      mol_graph_batch = self._batch_and_set(
          mol_graphs, atom_x, bond_x, False
      )
  
      result = {
          "mol_trees": mol_trees,
          "mol_graph_batch": mol_graph_batch,
      }
  
      if not self.training:
          return result
  
      # batch candidate graphs
      cand_graphs = _unpack_field(examples, "cand_graphs")
      cand_batch_idx = []
      atom_x = torch.cat(_unpack_field(examples, "atom_x_dec"))
      bond_x = torch.cat(_unpack_field(examples, "bond_x_dec"))
      tree_mess_src_e = _unpack_field(examples, "tree_mess_src_e")
      tree_mess_tgt_e = _unpack_field(examples, "tree_mess_tgt_e")
      tree_mess_tgt_n = _unpack_field(examples, "tree_mess_tgt_n")
  
      n_graph_nodes = 0
      n_tree_nodes = 0
      for i in range(len(cand_graphs)):
          tree_mess_tgt_e[i] += n_graph_nodes
          tree_mess_src_e[i] += n_tree_nodes
          tree_mess_tgt_n[i] += n_graph_nodes
          n_graph_nodes += sum(g.num_nodes() for g in cand_graphs[i])
          n_tree_nodes += mol_trees[i].graph.num_nodes()
          cand_batch_idx.extend([i] * len(cand_graphs[i]))
      tree_mess_tgt_e = torch.cat(tree_mess_tgt_e)
      tree_mess_src_e = torch.cat(tree_mess_src_e)
      tree_mess_tgt_n = torch.cat(tree_mess_tgt_n)
  
      cand_graph_batch = self._batch_and_set(
          cand_graphs, atom_x, bond_x, True
      )
  
      # batch stereoisomers
      stereo_cand_graphs = _unpack_field(examples, "stereo_cand_graphs")
      atom_x = torch.cat(_unpack_field(examples, "stereo_atom_x_enc"))
      bond_x = torch.cat(_unpack_field(examples, "stereo_bond_x_enc"))
      stereo_cand_batch_idx = []
      for i in range(len(stereo_cand_graphs)):
          stereo_cand_batch_idx.extend([i] * len(stereo_cand_graphs[i]))
  
      if len(stereo_cand_batch_idx) > 0:
          stereo_cand_labels = [
              (label, length)
              for ex in _unpack_field(examples, "stereo_cand_label")
              for label, length in ex
          ]
          stereo_cand_labels, stereo_cand_lengths = zip(
              *stereo_cand_labels
          )
          stereo_cand_graph_batch = self._batch_and_set(
              stereo_cand_graphs, atom_x, bond_x, True
          )
      else:
          stereo_cand_labels = []
          stereo_cand_lengths = []
          stereo_cand_graph_batch = None
          stereo_cand_batch_idx = []
  
      result.update(
          {
              "cand_graph_batch": cand_graph_batch,
              "cand_batch_idx": cand_batch_idx,
              "tree_mess_tgt_e": tree_mess_tgt_e,
              "tree_mess_src_e": tree_mess_src_e,
              "tree_mess_tgt_n": tree_mess_tgt_n,
              "stereo_cand_graph_batch": stereo_cand_graph_batch,
              "stereo_cand_batch_idx": stereo_cand_batch_idx,
              "stereo_cand_labels": stereo_cand_labels,
              "stereo_cand_lengths": stereo_cand_lengths,
          }
      )
  
      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 JTNNCollator obj's underlying member method code with example usage: obj.__call__(examples) and returns: result, result