class_docstr: Implements DTNN models for regression.
  
  DTNN is based on the many-body Hamiltonian concept, which is a fundamental principle in quantum mechanics.
  DTNN recieves a molecule's distance matrix and membership of its atom from its Coulomb Matrix representation.
  Then, it iteratively refines the representation of each atom by considering its interactions with neighboring atoms.
  Finally, it predicts the energy of the molecule by summing up the energies of the individual atoms.
  
  This class implements the Deep Tensor Neural Network (DTNN) [1]_.
  
  Examples
  --------
  >>> import os
  >>> from deepchem.data import SDFLoader
  >>> from deepchem.feat import CoulombMatrix
  >>> from deepchem.models.torch_models import DTNNModel
  >>> model_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  >>> dataset_file = os.path.join(model_dir, 'tests/assets/qm9_mini.sdf')
  >>> TASKS = ["alpha", "homo"]
  >>> loader = SDFLoader(tasks=TASKS, featurizer=CoulombMatrix(29), sanitize=True)
  >>> data = loader.create_dataset(dataset_file, shard_size=100)
  >>> n_tasks = data.y.shape[1]
  >>> model = DTNNModel(n_tasks,
  ...                   n_embedding=20,
  ...                   n_distance=100,
  ...                   learning_rate=1.0,
  ...                   mode="regression")
  >>> loss = model.fit(data, nb_epoch=250)
  >>> pred = model.predict(data)
  
  References
  ----------
  .. [1] Schütt, Kristof T., et al. "Quantum-chemical insights from deep
      tensor neural networks." Nature communications 8.1 (2017): 1-8.
docstr: Create a generator that iterates batches for a dataset.
  It processes inputs through the _compute_features_on_batch function to calculate required features of input.
  
  Parameters
  ----------
  dataset: Dataset
      the data to iterate
  epochs: int
      the number of times to iterate over the full dataset
  mode: str
      allowed values are 'fit' (called during training), 'predict' (called
      during prediction), and 'uncertainty' (called during uncertainty
      prediction)
  deterministic: bool
      whether to iterate over the dataset in order, or randomly shuffle the
      data for each epoch
  pad_batches: bool
      whether to pad each batch up to this model's preferred batch size
  
  Returns
  -------
  a generator that iterates batches, each represented as a tuple of lists:
  ([inputs], [outputs], [weights])
docstr_tok: ["Create","a","generator","that","iterates","batches","for","a","dataset",".","It","processes","inputs","through","the","_compute_features_on_batch","function","to","calculate","required","features","of","input",".","Parameters","--","--","--","--","--","dataset",":","Dataset","the","data","to","iterate","epochs",":","int","the","number","of","times","to","iterate","over","the","full","dataset","mode",":","str","allowed","values","are","'fit","'","(","called","during","training",")",",","'predict","'","(","called","during","prediction",")",",","and","'uncertainty","'","(","called","during","uncertainty","prediction",")","deterministic",":","bool","whether","to","iterate","over","the","dataset","in","order",",","or","randomly","shuffle","the","data","for","each","epoch","pad_batches",":","bool","whether","to","pad","each","batch","up","to","this","model","'s","preferred","batch","size","Returns","--","--","--","-","a","generator","that","iterates","batches",",","each","represented","as","a","tuple","of","lists",":","(","[","inputs","]",",","[","outputs","]",",","[","weights","]",")"]
code: def default_generator(
      self,
      dataset: Dataset,
      epochs: int = 1,
      mode: str = "fit",
      deterministic: bool = True,
      pad_batches: bool = True,
  ):
      """Create a generator that iterates batches for a dataset.
      It processes inputs through the _compute_features_on_batch function to calculate required features of input.
  
      Parameters
      ----------
      dataset: Dataset
          the data to iterate
      epochs: int
          the number of times to iterate over the full dataset
      mode: str
          allowed values are 'fit' (called during training), 'predict' (called
          during prediction), and 'uncertainty' (called during uncertainty
          prediction)
      deterministic: bool
          whether to iterate over the dataset in order, or randomly shuffle the
          data for each epoch
      pad_batches: bool
          whether to pad each batch up to this model's preferred batch size
  
      Returns
      -------
      a generator that iterates batches, each represented as a tuple of lists:
      ([inputs], [outputs], [weights])
  
      """
      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,
          ):
              yield (
                  batch_coulomb_matrix_features(
                      X_b,
                      self.model.distance_max,
                      self.model.distance_min,
                      self.model.n_distance,
                  ),
                  [y_b],
                  [w_b],
              )
  
file_path: deepchem/deepchem/models/torch_models/dtnn.py
imports: from typing import List
  import torch.nn
  import torch
  from deepchem.models.losses import L2Loss
  from deepchem.models.torch_models import layers
  from deepchem.models.torch_models import TorchModel
  from deepchem.data.datasets import Dataset
  from deepchem.utils import batch_coulomb_matrix_features
label_desc: Use image node_id 2 for calling the DTNNModel obj's underlying member method code with example usage: obj.default_generator(dataset, epochs, mode, deterministic, pad_batches) without return types