class_docstr: Model for graph property prediction
  
  This model proceeds as follows:
  
  * Combine latest node representations and edge features in updating node representations,
      which involves multiple rounds of message passing
  * For each graph, compute its representation by combining the representations
      of all nodes in it, which involves a Set2Set layer.
  * Perform the final prediction using an MLP
  Examples
  --------
  >>> import deepchem as dc
  >>> from deepchem.models.torch_models import MPNNModel
  >>> # preparing dataset
  >>> smiles = ["C1CCC1", "CCC"]
  >>> labels = [0., 1.]
  >>> featurizer = dc.feat.MolGraphConvFeaturizer(use_edges=True)
  >>> X = featurizer.featurize(smiles)
  >>> dataset = dc.data.NumpyDataset(X=X, y=labels)
  >>> # training model
  >>> model = MPNNModel(mode='classification', n_tasks=1,
  ...                  batch_size=16, learning_rate=0.001)
  >>> loss =  model.fit(dataset, nb_epoch=5)
  
  References
  ----------
  .. [1] Justin Gilmer, Samuel S. Schoenholz, Patrick F. Riley, Oriol Vinyals, George E. Dahl.
      "Neural Message Passing for Quantum Chemistry." ICML 2017.
  
  Notes
  -----
  This class requires DGL (https://github.com/dmlc/dgl) and DGL-LifeSci
  (https://github.com/awslabs/dgl-lifesci) to be installed.
  
  The featurizer used with MPNNModel must produce a GraphData object which should have both 'edge' and 'node' features.
docstr: Parameters
  ----------
  n_tasks: int
      Number of tasks.
  node_out_feats: int
      The length of the final node representation vectors. Default to 64.
  edge_hidden_feats: int
      The length of the hidden edge representation vectors. Default to 128.
  num_step_message_passing: int
      The number of rounds of message passing. Default to 3.
  num_step_set2set: int
      The number of set2set steps. Default to 6.
  num_layer_set2set: int
      The number of set2set layers. Default to 3.
  mode: str
      The model type, 'classification' or 'regression'. Default to 'regression'.
  number_atom_features: int
      The length of the initial atom feature vectors. Default to 30.
  number_bond_features: int
      The length of the initial bond feature vectors. Default to 11.
  n_classes: int
      The number of classes to predict per task
      (only used when ``mode`` is 'classification'). Default to 2.
  self_loop: bool
      Whether to add self loops for the nodes, i.e. edges from nodes to themselves.
      Generally, an MPNNModel does not require self loops. Default to False.
  kwargs
      This can include any keyword argument of TorchModel.
code: def __init__(
      self,
      n_tasks: int,
      node_out_feats: int = 64,
      edge_hidden_feats: int = 128,
      num_step_message_passing: int = 3,
      num_step_set2set: int = 6,
      num_layer_set2set: int = 3,
      mode: str = "regression",
      number_atom_features: int = 30,
      number_bond_features: int = 11,
      n_classes: int = 2,
      self_loop: bool = False,
      **kwargs,
  ):
      """
      Parameters
      ----------
      n_tasks: int
          Number of tasks.
      node_out_feats: int
          The length of the final node representation vectors. Default to 64.
      edge_hidden_feats: int
          The length of the hidden edge representation vectors. Default to 128.
      num_step_message_passing: int
          The number of rounds of message passing. Default to 3.
      num_step_set2set: int
          The number of set2set steps. Default to 6.
      num_layer_set2set: int
          The number of set2set layers. Default to 3.
      mode: str
          The model type, 'classification' or 'regression'. Default to 'regression'.
      number_atom_features: int
          The length of the initial atom feature vectors. Default to 30.
      number_bond_features: int
          The length of the initial bond feature vectors. Default to 11.
      n_classes: int
          The number of classes to predict per task
          (only used when ``mode`` is 'classification'). Default to 2.
      self_loop: bool
          Whether to add self loops for the nodes, i.e. edges from nodes to themselves.
          Generally, an MPNNModel does not require self loops. Default to False.
      kwargs
          This can include any keyword argument of TorchModel.
      """
      model = MPNN(
          n_tasks=n_tasks,
          node_out_feats=node_out_feats,
          edge_hidden_feats=edge_hidden_feats,
          num_step_message_passing=num_step_message_passing,
          num_step_set2set=num_step_set2set,
          num_layer_set2set=num_layer_set2set,
          mode=mode,
          number_atom_features=number_atom_features,
          number_bond_features=number_bond_features,
          n_classes=n_classes,
      )
      if mode == "regression":
          loss: Loss = L2Loss()
          output_types = ["prediction"]
      else:
          loss = SparseSoftmaxCrossEntropy()
          output_types = ["prediction", "loss"]
      super(MPNNModel, self).__init__(
          model, loss=loss, output_types=output_types, **kwargs
      )
  
      self._self_loop = self_loop
  
file_path: deepchem/deepchem/models/torch_models/mpnn.py
imports: import torch.nn
  import torch.nn.functional
  from deepchem.models.losses import Loss, L2Loss, SparseSoftmaxCrossEntropy
  from deepchem.models.torch_models.torch_model import TorchModel
label_desc: Use image node_id 1 to create a new MPNNModel object from inherited base classes: TorchModel with example: obj = MPNNModel(n_tasks, node_out_feats, edge_hidden_feats, num_step_message_passing, num_step_set2set, num_layer_set2set, mode, number_atom_features, number_bond_features, n_classes, _loop)