class_docstr: Message Passing Neural Network,
  
  Message Passing Neural Networks [1]_ treat graph convolutional
  operations as an instantiation of a more general message
  passing schem. Recall that message passing in a graph is when
  nodes in a graph send each other "messages" and update their
  internal state as a consequence of these messages.
  
  Ordering structures in this model are built according to [2]_
  
  References
  ----------
  .. [1] Justin Gilmer, Samuel S. Schoenholz, Patrick F. Riley, Oriol Vinyals, George E. Dahl.
      "Neural Message Passing for Quantum Chemistry." ICML 2017.
  .. [2] Vinyals, Oriol, Samy Bengio, and Manjunath Kudlur. "Order matters:
      Sequence to sequence for sets." arXiv preprint arXiv:1511.06391 (2015).
class_docstr_tok: ["Message","Passing","Neural","Network",",","Message","Passing","Neural","Networks","[","1","]","_","treat","graph","convolutional","operations","as","an","instantiation","of","a","more","general","message","passing","schem",".","Recall","that","message","passing","in","a","graph","is","when","nodes","in","a","graph","send","each","other","``","messages","''","and","update","their","internal","state","as","a","consequence","of","these","messages",".","Ordering","structures","in","this","model","are","built","according","to","[","2","]","_","References","--","--","--","--","--","..","[","1","]","Justin","Gilmer",",","Samuel","S.","Schoenholz",",","Patrick","F.","Riley",",","Oriol","Vinyals",",","George","E.","Dahl",".","``","Neural","Message","Passing","for","Quantum","Chemistry",".","''","ICML","2017",".","..","[","2","]","Vinyals",",","Oriol",",","Samy","Bengio",",","and","Manjunath","Kudlur",".","``","Order","matters",":","Sequence","to","sequence","for","sets",".","''","arXiv","preprint","arXiv:1511.06391","(","2015",")","."]
code: def default_generator(
      self,
      dataset,
      epochs=1,
      mode="fit",
      deterministic=True,
      pad_batches=True,
  ):
      for epoch in range(epochs):
          for X_b, y_b, w_b, ids_b in dataset.iterbatches(
              batch_size=self.batch_size,
              deterministic=deterministic,
              pad_batches=pad_batches,
          ):
              n_samples = np.array(X_b.shape[0])
              X_b = pad_features(self.batch_size, X_b)
              if y_b is not None and self.mode == "classification":
                  y_b = to_one_hot(
                      y_b.flatten(), self.n_classes
                  ).reshape(-1, self.n_tasks, self.n_classes)
  
              atom_feat = []
              pair_feat = []
              atom_split = []
              atom_to_pair = []
              pair_split = []
              start = 0
              for im, mol in enumerate(X_b):
                  n_atoms = mol.get_num_atoms()
                  # number of atoms in each molecule
                  atom_split.extend([im] * n_atoms)
                  # index of pair features
                  C0, C1 = np.meshgrid(
                      np.arange(n_atoms), np.arange(n_atoms)
                  )
                  atom_to_pair.append(
                      np.transpose(
                          np.array(
                              [
                                  C1.flatten() + start,
                                  C0.flatten() + start,
                              ]
                          )
                      )
                  )
                  # number of pairs for each atom
                  pair_split.extend(C1.flatten() + start)
                  start = start + n_atoms
  
                  # atom features
                  atom_feat.append(mol.get_atom_features())
                  # pair features
                  pair_feat.append(
                      np.reshape(
                          mol.get_pair_features(),
                          (n_atoms * n_atoms, self.n_pair_feat),
                      )
                  )
  
              inputs = [
                  np.concatenate(atom_feat, axis=0),
                  np.concatenate(pair_feat, axis=0),
                  np.array(atom_split),
                  np.concatenate(atom_to_pair, axis=0),
                  n_samples,
              ]
              yield (inputs, [y_b], [w_b])
  
imports: from collections.abc import Sequence
  import deepchem
  import numpy
  import tensorflow
  from typing import List, Union, Tuple, Iterable, Dict, Optional
  from deepchem.utils.typing import OneOrMany, LossFn, ActivationFn
  from deepchem.data import Dataset, pad_features
  from deepchem.feat.mol_graphs import ConvMol
  from deepchem.metrics import to_one_hot
  from deepchem.models import KerasModel, layers
  from deepchem.models.losses import L2Loss, SoftmaxCrossEntropy, Loss
  from tensorflow.keras.layers import Input, Dense, Reshape, Softmax, Dropout, Activation, BatchNormalization
  import warnings
label_desc: Use image node_id 2 for calling the MPNNModel obj's underlying member method code with example usage: obj.default_generator(dataset, epochs, mode, deterministic, pad_batches) without return types