class_docstr: Molecular Attention Transformer.
  
  This class implements the Molecular Attention Transformer [1]_.
  The MATFeaturizer (deepchem.feat.MATFeaturizer) is intended to work with this class.
  The model takes a batch of MATEncodings (from MATFeaturizer) as input, and returns an array of size Nx1, where N is the number of molecules in the batch.
  Each molecule is broken down into its Node Features matrix, adjacency matrix and distance matrix.
  A mask tensor is calculated for the batch. All of this goes as input to the MATEmbedding, MATEncoder and MATGenerator layers, which are defined in deepchem.models.torch_models.layers.py
  
  Currently, MATModel is intended to be a regression model for the freesolv dataset.
  
  References
  ----------
  .. [1] Lukasz Maziarka et al. "Molecule Attention Transformer" Graph Representation Learning workshop and Machine Learning and the Physical Sciences workshop at NeurIPS 2019. 2020. https://arxiv.org/abs/2002.08264
  
  Examples
  --------
  >>> import deepchem as dc
  >>> import pandas as pd
  >>> smiles = ['CC', 'CCC',  'CCCC', 'CCCCC', 'CCCCCCC']
  >>> vals = [1.35, 6.72, 5.67, 1.23, 1.76]
  >>> df = pd.DataFrame(list(zip(smiles, vals)), columns = ['smiles', 'y'])
  >>> loader = dc.data.CSVLoader(tasks=['y'], feature_field='smiles', featurizer=dc.feat.MATFeaturizer())
  >>> df.to_csv('test.csv')
  >>> dataset = loader.create_dataset('test.csv')
  >>> model = dc.models.torch_models.MATModel(batch_size = 2)
  >>> out = model.fit(dataset, nb_epoch = 1)
class_docstr_tok: ["Molecular","Attention","Transformer",".","This","class","implements","the","Molecular","Attention","Transformer","[","1","]","_",".","The","MATFeaturizer","(","deepchem.feat.MATFeaturizer",")","is","intended","to","work","with","this","class",".","The","model","takes","a","batch","of","MATEncodings","(","from","MATFeaturizer",")","as","input",",","and","returns","an","array","of","size","Nx1",",","where","N","is","the","number","of","molecules","in","the","batch",".","Each","molecule","is","broken","down","into","its","Node","Features","matrix",",","adjacency","matrix","and","distance","matrix",".","A","mask","tensor","is","calculated","for","the","batch",".","All","of","this","goes","as","input","to","the","MATEmbedding",",","MATEncoder","and","MATGenerator","layers",",","which","are","defined","in","deepchem.models.torch_models.layers.py","Currently",",","MATModel","is","intended","to","be","a","regression","model","for","the","freesolv","dataset",".","References","--","--","--","--","--","..","[","1","]","Lukasz","Maziarka","et","al",".","``","Molecule","Attention","Transformer","''","Graph","Representation","Learning","workshop","and","Machine","Learning","and","the","Physical","Sciences","workshop","at","NeurIPS","2019",".","2020.","https",":","\/\/arxiv.org\/abs\/2002.08264","Examples","--","--","--","--",">",">",">","import","deepchem","as","dc",">",">",">","import","pandas","as","pd",">",">",">","smiles","=","[","'CC","'",",","'CCC","'",",","'CCCC","'",",","'CCCCC","'",",","'CCCCCCC","'","]",">",">",">","vals","=","[","1.35",",","6.72",",","5.67",",","1.23",",","1.76","]",">",">",">","df","=","pd.DataFrame","(","list","(","zip","(","smiles",",","vals",")",")",",","columns","=","[","'smiles","'",",","'","y","'","]",")",">",">",">","loader","=","dc.data.CSVLoader","(","tasks=","[","'","y","'","]",",","feature_field='smiles","'",",","featurizer=dc.feat.MATFeaturizer","(",")",")",">",">",">","df.to_csv","(","'test.csv","'",")",">",">",">","dataset","=","loader.create_dataset","(","'test.csv","'",")",">",">",">","model","=","dc.models.torch_models.MATModel","(","batch_size","=","2",")",">",">",">","out","=","model.fit","(","dataset",",","nb_epoch","=","1",")"]
docstr: Pads a given sequence using the pad_array function.
  
  Parameters
  ----------
  sequence: np.ndarray
  Arrays in this sequence are padded to the largest shape in the sequence.
  
  Returns
  ----------
  array: np.ndarray
  Sequence with padded arrays.
docstr_tok: ["Pads","a","given","sequence","using","the","pad_array","function",".","Parameters","--","--","--","--","--","sequence",":","np.ndarray","Arrays","in","this","sequence","are","padded","to","the","largest","shape","in","the","sequence",".","Returns","--","--","--","--","--","array",":","np.ndarray","Sequence","with","padded","arrays","."]
code: def pad_sequence(self, sequence: np.ndarray) -> np.ndarray:
      """
      Pads a given sequence using the pad_array function.
  
      Parameters
      ----------
      sequence: np.ndarray
      Arrays in this sequence are padded to the largest shape in the sequence.
  
      Returns
      ----------
      array: np.ndarray
      Sequence with padded arrays.
      """
      shapes = np.stack([np.array(t.shape) for t in sequence])
      max_shape = tuple(np.max(shapes, axis=0))
      return np.stack(
          [self.pad_array(t, shape=max_shape) for t in sequence]
      )
  
file_path: deepchem/deepchem/models/torch_models/mat.py
imports: import torch
  import torch.nn
  import numpy
  from deepchem.models.torch_models import layers
  from deepchem.models.torch_models.torch_model import TorchModel
  from deepchem.models.losses import L2Loss
  from typing import Any
label_desc: Use image node_id 3 for calling the MATModel obj's underlying member method code with example usage: obj.pad_sequence(sequence) and returns: np