class_docstr: Deep Tensor Neural Networks
  
  This class implements deep tensor neural networks as first defined in [1]_
  
  References
  ----------
  .. [1] Schütt, Kristof T., et al. "Quantum-chemical insights from deep
      tensor neural networks." Nature communications 8.1 (2017): 1-8.
class_docstr_tok: ["Deep","Tensor","Neural","Networks","This","class","implements","deep","tensor","neural","networks","as","first","defined","in","[","1","]","_","References","--","--","--","--","--","..","[","1","]","Sch\u00fctt",",","Kristof","T.",",","et","al",".","``","Quantum-chemical","insights","from","deep","tensor","neural","networks",".","''","Nature","communications","8.1","(","2017",")",":","1-8","."]
docstr: Parameters
  ----------
  n_tasks: int
      Number of tasks
  n_embedding: int, optional
      Number of features per atom.
  n_hidden: int, optional
      Number of features for each molecule after DTNNStep
  n_distance: int, optional
      granularity of distance matrix
      step size will be (distance_max-distance_min)/n_distance
  distance_min: float, optional
      minimum distance of atom pairs, default = -1 Angstorm
  distance_max: float, optional
      maximum distance of atom pairs, default = 18 Angstorm
  mode: str
      Only "regression" is currently supported.
  dropout: float
      the dropout probablity to use.
docstr_tok: ["Parameters","--","--","--","--","--","n_tasks",":","int","Number","of","tasks","n_embedding",":","int",",","optional","Number","of","features","per","atom",".","n_hidden",":","int",",","optional","Number","of","features","for","each","molecule","after","DTNNStep","n_distance",":","int",",","optional","granularity","of","distance","matrix","step","size","will","be","(","distance_max-distance_min",")","\/n_distance","distance_min",":","float",",","optional","minimum","distance","of","atom","pairs",",","default","=","-1","Angstorm","distance_max",":","float",",","optional","maximum","distance","of","atom","pairs",",","default","=","18","Angstorm","mode",":","str","Only","``","regression","''","is","currently","supported",".","dropout",":","float","the","dropout","probablity","to","use","."]
code: def __init__(
      self,
      n_tasks,
      n_embedding=30,
      n_hidden=100,
      n_distance=100,
      distance_min=-1,
      distance_max=18,
      output_activation=True,
      mode="regression",
      dropout=0.0,
      **kwargs,
  ):
      """
      Parameters
      ----------
      n_tasks: int
          Number of tasks
      n_embedding: int, optional
          Number of features per atom.
      n_hidden: int, optional
          Number of features for each molecule after DTNNStep
      n_distance: int, optional
          granularity of distance matrix
          step size will be (distance_max-distance_min)/n_distance
      distance_min: float, optional
          minimum distance of atom pairs, default = -1 Angstorm
      distance_max: float, optional
          maximum distance of atom pairs, default = 18 Angstorm
      mode: str
          Only "regression" is currently supported.
      dropout: float
          the dropout probablity to use.
      """
      if mode not in ["regression"]:
          raise ValueError(
              "Only 'regression' mode is currently supported"
          )
      self.n_tasks = n_tasks
      self.n_embedding = n_embedding
      self.n_hidden = n_hidden
      self.n_distance = n_distance
      self.distance_min = distance_min
      self.distance_max = distance_max
      self.step_size = (distance_max - distance_min) / n_distance
      self.steps = np.array(
          [distance_min + i * self.step_size for i in range(n_distance)]
      )
      self.steps = np.expand_dims(self.steps, 0)
      self.output_activation = output_activation
      self.mode = mode
      self.dropout = dropout
  
      # Build the model.
  
      atom_number = Input(shape=tuple(), dtype=tf.int32)
      distance = Input(shape=(self.n_distance,))
      atom_membership = Input(shape=tuple(), dtype=tf.int32)
      distance_membership_i = Input(shape=tuple(), dtype=tf.int32)
      distance_membership_j = Input(shape=tuple(), dtype=tf.int32)
  
      dtnn_embedding = layers.DTNNEmbedding(
          n_embedding=self.n_embedding
      )(atom_number)
      if self.dropout > 0.0:
          dtnn_embedding = Dropout(rate=self.dropout)(dtnn_embedding)
      dtnn_layer1 = layers.DTNNStep(
          n_embedding=self.n_embedding, n_distance=self.n_distance
      )(
          [
              dtnn_embedding,
              distance,
              distance_membership_i,
              distance_membership_j,
          ]
      )
      if self.dropout > 0.0:
          dtnn_layer1 = Dropout(rate=self.dropout)(dtnn_layer1)
      dtnn_layer2 = layers.DTNNStep(
          n_embedding=self.n_embedding, n_distance=self.n_distance
      )(
          [
              dtnn_layer1,
              distance,
              distance_membership_i,
              distance_membership_j,
          ]
      )
      if self.dropout > 0.0:
          dtnn_layer2 = Dropout(rate=self.dropout)(dtnn_layer2)
      dtnn_gather = layers.DTNNGather(
          n_embedding=self.n_embedding,
          layer_sizes=[self.n_hidden],
          n_outputs=self.n_tasks,
          output_activation=self.output_activation,
      )([dtnn_layer2, atom_membership])
      if self.dropout > 0.0:
          dtnn_gather = Dropout(rate=self.dropout)(dtnn_gather)
  
      n_tasks = self.n_tasks
      output = Dense(n_tasks)(dtnn_gather)
      model = tf.keras.Model(
          inputs=[
              atom_number,
              distance,
              atom_membership,
              distance_membership_i,
              distance_membership_j,
          ],
          outputs=[output],
      )
      super(DTNNModel, self).__init__(model, L2Loss(), **kwargs)
  
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 1 to create a new DTNNModel object from inherited base classes: KerasModel with example: obj = DTNNModel(n_tasks, n_embedding, n_hidden, n_distance, distance_min, distance_max, output_activation, mode, dropout)