class_docstr:     This class is a helper class for DMPNNModel class to generate concatenated feature vector and mappings.
  
      `self.f_ini_atoms_bonds` is the concatenated feature vector which contains
      concatenation of initial atom and bond features.
  
      `self.atom_to_incoming_bonds` is mapping from atom index to list of indicies of incoming bonds.
  
      `self.mapping` is the mapping that maps bond index to 'array of indices of the bonds'
      incoming at the initial atom of the bond (excluding the reverse bonds)
  
      Example,
      Let the diagram given below represent a molecule containing 3 atoms (nodes) and 2 bonds (edges):-
  
      |   0 --- 1
      |   |
      |   2
  
      Here, atoms are => A0, A1 and A2 and their respective feature vectors are f0, f1, and f2.
  
      Let the bonds from atoms 0->1 ('B[01]') and 1->0 ('B[10]') be considered as 2 different bonds.
      Hence, by considering the same for all atoms, the total number of bonds = 4.
  
      Let:
          B[01] => B0
          B[10] => B1
          B[02] => B2
          B[20] => B3
  
      Hence repective bond features are fb0, fb1, fb2, and fb3.
      (Note: fb0 = fb1, fb2 = fb3)
  
      'f_ini_atoms_bonds' is the concatenated feature vector which contains
      concatenation of initial atom and bond features.
  
      'B0'
      Example: 'A0' -----> A1 , concat feature = f0 + fb0
  
      Hence,
          B0       B1       B2       B3     B(-1)
      f_ini_atoms_bonds = [ f0+fb0 , f1+fb1 , f0+fb2 , f2+fb3 , f(-1) ]
  
      (Note: f(-1) is a zero array of the same size as other concatenated features.)
  
      `atom_to_incoming_bonds` is mapping from atom index to list of indicies of incoming bonds.
  
      B3          B1
      Example: 'A2' ----> 'A0' <---- 'A1', for A0 => [B1, B3]
  
      Hence,
          A0        A1        A2
      atom_to_incoming_bonds = [ [B1,B3] [B0,B(-1)] [B2,B(-1)] ]
  
      (Note: Here, maximum number of incoming bonds is 2. So, -1 index is added to all those cases
          where number of incoming bonds is less than maximum. In this case, its for A1 and A2.)
  
      To get mapping, first find indices of the bonds, incoming at the initial atom of the bond.
  
      Example: for bond B0, B1 and B3 are coming towards atom 0.
  
      |                    B0             B1
      |                 0 ----> 1  |  0 <---- 1
      |                            |  ^
      |                            |  | B3
      |                            |  2
  
      B0     B1    B2     B3
  mapping (with reverse bonds) = [ [B1,B3] [B0] [B1,B3] [B2] ]
  
      To get the required mapping, reverse bond indices are replaced with -1
      and extra space in the array elements is filled with -1, to get a uniform array.
  
      The mapping is also padded with -1 at the end, so that the length of `mapping` is
      equal to the length of `f_ini_atoms_bonds`.
  
      Hence,
          B0          B1          B2            B3          B(-1)
      mapping = [ [B(-1),B3] [B(-1),B(-1)] [B1,B(-1)] [B(-1),B(-1)] [B(-1),B(-1)] ]
  
      OR
  
      mapping = [[-1, 3], [-1, -1], [1, -1], [-1, -1], [-1, -1]]
      
class_docstr_tok: ["This","class","is","a","helper","class","for","DMPNNModel","class","to","generate","concatenated","feature","vector","and","mappings",".","`","self.f_ini_atoms_bonds","`","is","the","concatenated","feature","vector","which","contains","concatenation","of","initial","atom","and","bond","features",".","`","self.atom_to_incoming_bonds","`","is","mapping","from","atom","index","to","list","of","indicies","of","incoming","bonds",".","`","self.mapping","`","is","the","mapping","that","maps","bond","index","to","'array","of","indices","of","the","bonds'","incoming","at","the","initial","atom","of","the","bond","(","excluding","the","reverse","bonds",")","Example",",","Let","the","diagram","given","below","represent","a","molecule","containing","3","atoms","(","nodes",")","and","2","bonds","(","edges",")",":","-","|","0","--","-","1","|","|","|","2","Here",",","atoms","are","=",">","A0",",","A1","and","A2","and","their","respective","feature","vectors","are","f0",",","f1",",","and","f2",".","Let","the","bonds","from","atoms","0-",">","1","(","'","B","[","01","]","'",")","and","1-",">","0","(","'","B","[","10","]","'",")","be","considered","as","2","different","bonds",".","Hence",",","by","considering","the","same","for","all","atoms",",","the","total","number","of","bonds","=","4",".","Let",":","B","[","01","]","=",">","B0","B","[","10","]","=",">","B1","B","[","02","]","=",">","B2","B","[","20","]","=",">","B3","Hence","repective","bond","features","are","fb0",",","fb1",",","fb2",",","and","fb3",".","(","Note",":","fb0","=","fb1",",","fb2","=","fb3",")","'f_ini_atoms_bonds","'","is","the","concatenated","feature","vector","which","contains","concatenation","of","initial","atom","and","bond","features",".","'B0'","Example",":","'A0","'","--","--","-",">","A1",",","concat","feature","=","f0","+","fb0","Hence",",","B0","B1","B2","B3","B","(","-1",")","f_ini_atoms_bonds","=","[","f0+fb0",",","f1+fb1",",","f0+fb2",",","f2+fb3",",","f","(","-1",")","]","(","Note",":","f","(","-1",")","is","a","zero","array","of","the","same","size","as","other","concatenated","features",".",")","`","atom_to_incoming_bonds","`","is","mapping","from","atom","index","to","list","of","indicies","of","incoming","bonds",".","B3","B1","Example",":","'A2","'","--","--",">","'A0","'","<","--","--","'A1","'",",","for","A0","=",">","[","B1",",","B3","]","Hence",",","A0","A1","A2","atom_to_incoming_bonds","=","[","[","B1",",","B3","]","[","B0",",","B","(","-1",")","]","[","B2",",","B","(","-1",")","]","]","(","Note",":","Here",",","maximum","number","of","incoming","bonds","is","2",".","So",",","-1","index","is","added","to","all","those","cases","where","number","of","incoming","bonds","is","less","than","maximum",".","In","this","case",",","its","for","A1","and","A2",".",")","To","get","mapping",",","first","find","indices","of","the","bonds",",","incoming","at","the","initial","atom","of","the","bond",".","Example",":","for","bond","B0",",","B1","and","B3","are","coming","towards","atom","0",".","|","B0","B1","|","0","--","--",">","1","|","0","<","--","--","1","|","|","^","|","|","|","B3","|","|","2","B0","B1","B2","B3","mapping","(","with","reverse","bonds",")","=","[","[","B1",",","B3","]","[","B0","]","[","B1",",","B3","]","[","B2","]","]","To","get","the","required","mapping",",","reverse","bond","indices","are","replaced","with","-1","and","extra","space","in","the","array","elements","is","filled","with","-1",",","to","get","a","uniform","array",".","The","mapping","is","also","padded","with","-1","at","the","end",",","so","that","the","length","of","`","mapping","`","is","equal","to","the","length","of","`","f_ini_atoms_bonds","`",".","Hence",",","B0","B1","B2","B3","B","(","-1",")","mapping","=","[","[","B","(","-1",")",",","B3","]","[","B","(","-1",")",",","B","(","-1",")","]","[","B1",",","B","(","-1",")","]","[","B","(","-1",")",",","B","(","-1",")","]","[","B","(","-1",")",",","B","(","-1",")","]","]","OR","mapping","=","[","[","-1",",","3","]",",","[","-1",",","-1","]",",","[","1",",","-1","]",",","[","-1",",","-1","]",",","[","-1",",","-1","]","]"]
docstr: Returns the required mappings:
  - atom features
  - concat features (atom + bond)
  - atom to incoming bonds mapping
  - mapping
  - global features
docstr_tok: ["Returns","the","required","mappings",":","-","atom","features","-","concat","features","(","atom","+","bond",")","-","atom","to","incoming","bonds","mapping","-","mapping","-","global","features"]
code: def values(self) -> Sequence[np.ndarray]:
      """
      Returns the required mappings:
      - atom features
      - concat features (atom + bond)
      - atom to incoming bonds mapping
      - mapping
      - global features
      """
      return (
          self.atom_features,
          self.f_ini_atoms_bonds,
          self.atom_to_incoming_bonds,
          self.mapping,
          self.global_features,
      )
  
imports: import numpy
  import torch
  import torch.nn
  from deepchem.models.losses import Loss, L2Loss, SparseSoftmaxCrossEntropy
  from deepchem.models.torch_models import layers
  from deepchem.models.torch_models import TorchModel
  from torch_geometric.data import Data, Batch
  from deepchem.feat import GraphData
  from deepchem.data import Dataset
  from typing import Union, List, Sequence, Optional, Iterable, Tuple
label_desc: Use image node_id 2 for calling the _MapperDMPNN obj's underlying member method code with example usage: obj.values() and returns: self,  self,  self,  self,  self