code: def tensorize_nodes(node_batch, scope):
      messages, mess_dict = [None], {}
      fnode = []
      for x in node_batch:
          fnode.append(x.wid)
          for y in x.neighbors:
              mess_dict[(x.idx, y.idx)] = len(messages)
              messages.append((x, y))
  
      node_graph = [[] for i in range(len(node_batch))]
      mess_graph = [[] for i in range(len(messages))]
      fmess = [0] * len(messages)
  
      for x, y in messages[1:]:
          mid1 = mess_dict[(x.idx, y.idx)]
          fmess[mid1] = x.idx
          node_graph[y.idx].append(mid1)
          for z in y.neighbors:
              if z.idx == x.idx:
                  continue
              mid2 = mess_dict[(y.idx, z.idx)]
              mess_graph[mid2].append(mid1)
  
      max_len = max([len(t) for t in node_graph] + [1])
      for t in node_graph:
          pad_len = max_len - len(t)
          t.extend([0] * pad_len)
  
      max_len = max([len(t) for t in mess_graph] + [1])
      for t in mess_graph:
          pad_len = max_len - len(t)
          t.extend([0] * pad_len)
  
      mess_graph = torch.LongTensor(mess_graph)
      node_graph = torch.LongTensor(node_graph)
      fmess = torch.LongTensor(fmess)
      fnode = torch.LongTensor(fnode)
      return (fnode, fmess, node_graph, mess_graph, scope), mess_dict
  
file_path: DIG/dig/ggraph/method/JTVAE/fast_jtnn/jtnn_enc.py
imports: import torch
  import torch.nn
  import torch.nn.functional
  from .mol_tree import Vocab, MolTree
  from .nnutils import create_var, index_select_ND
label_desc: Use image node_id 4 for calling the JTNNEncoder obj's underlying member method code with example usage: obj.tensorize_nodes(node_batch, scope) and returns: fnode,  fmess,  node_graph,  mess_graph,  scope,  mess_dict