class_docstr: This is a DeepChem model implemented by a PyTorch model.
  
  Here is a simple example of code that uses TorchModel to train
  a PyTorch model on a DeepChem dataset.
  
  >>> import torch
  >>> import deepchem as dc
  >>> import numpy as np
  >>> X, y = np.random.random((10, 100)), np.random.random((10, 1))
  >>> dataset = dc.data.NumpyDataset(X=X, y=y)
  >>> pytorch_model = torch.nn.Sequential(
  ...   torch.nn.Linear(100, 1000),
  ...   torch.nn.Tanh(),
  ...   torch.nn.Linear(1000, 1))
  >>> model = dc.models.TorchModel(pytorch_model, loss=dc.models.losses.L2Loss())
  >>> loss = model.fit(dataset, nb_epoch=5)
  
  The loss function for a model can be defined in two different
  ways.  For models that have only a single output and use a
  standard loss function, you can simply provide a
  dc.models.losses.Loss object.  This defines the loss for each
  sample or sample/task pair.  The result is automatically
  multiplied by the weights and averaged over the batch.
  
  For more complicated cases, you can instead provide a function
  that directly computes the total loss.  It must be of the form
  f(outputs, labels, weights), taking the list of outputs from
  the model, the expected values, and any weight matrices.  It
  should return a scalar equal to the value of the loss function
  for the batch.  No additional processing is done to the
  result; it is up to you to do any weighting, averaging, adding
  of penalty terms, etc.
  
  You can optionally provide an output_types argument, which
  describes how to interpret the model's outputs.  This should
  be a list of strings, one for each output. You can use an
  arbitrary output_type for a output, but some output_types are
  special and will undergo extra processing:
  
  - 'prediction': This is a normal output, and will be returned by predict().
      If output types are not specified, all outputs are assumed
      to be of this type.
  
  - 'loss': This output will be used in place of the normal
      outputs for computing the loss function.  For example,
      models that output probability distributions usually do it
      by computing unbounded numbers (the logits), then passing
      them through a softmax function to turn them into
      probabilities.  When computing the cross entropy, it is more
      numerically stable to use the logits directly rather than
      the probabilities.  You can do this by having the model
      produce both probabilities and logits as outputs, then
      specifying output_types=['prediction', 'loss'].  When
      predict() is called, only the first output (the
      probabilities) will be returned.  But during training, it is
      the second output (the logits) that will be passed to the
      loss function.
  
  - 'variance': This output is used for estimating the
      uncertainty in another output.  To create a model that can
      estimate uncertainty, there must be the same number of
      'prediction' and 'variance' outputs.  Each variance output
      must have the same shape as the corresponding prediction
      output, and each element is an estimate of the variance in
      the corresponding prediction.  Also be aware that if a model
      supports uncertainty, it MUST use dropout on every layer,
      and dropout most be enabled during uncertainty prediction.
      Otherwise, the uncertainties it computes will be inaccurate.
  
  - other: Arbitrary output_types can be used to extract outputs
      produced by the model, but will have no additional
      processing performed.
class_docstr_tok: ["This","is","a","DeepChem","model","implemented","by","a","PyTorch","model",".","Here","is","a","simple","example","of","code","that","uses","TorchModel","to","train","a","PyTorch","model","on","a","DeepChem","dataset",".",">",">",">","import","torch",">",">",">","import","deepchem","as","dc",">",">",">","import","numpy","as","np",">",">",">","X",",","y","=","np.random.random","(","(","10",",","100",")",")",",","np.random.random","(","(","10",",","1",")",")",">",">",">","dataset","=","dc.data.NumpyDataset","(","X=X",",","y=y",")",">",">",">","pytorch_model","=","torch.nn.Sequential","(","...","torch.nn.Linear","(","100",",","1000",")",",","...","torch.nn.Tanh","(",")",",","...","torch.nn.Linear","(","1000",",","1",")",")",">",">",">","model","=","dc.models.TorchModel","(","pytorch_model",",","loss=dc.models.losses.L2Loss","(",")",")",">",">",">","loss","=","model.fit","(","dataset",",","nb_epoch=5",")","The","loss","function","for","a","model","can","be","defined","in","two","different","ways",".","For","models","that","have","only","a","single","output","and","use","a","standard","loss","function",",","you","can","simply","provide","a","dc.models.losses.Loss","object",".","This","defines","the","loss","for","each","sample","or","sample\/task","pair",".","The","result","is","automatically","multiplied","by","the","weights","and","averaged","over","the","batch",".","For","more","complicated","cases",",","you","can","instead","provide","a","function","that","directly","computes","the","total","loss",".","It","must","be","of","the","form","f","(","outputs",",","labels",",","weights",")",",","taking","the","list","of","outputs","from","the","model",",","the","expected","values",",","and","any","weight","matrices",".","It","should","return","a","scalar","equal","to","the","value","of","the","loss","function","for","the","batch",".","No","additional","processing","is","done","to","the","result",";","it","is","up","to","you","to","do","any","weighting",",","averaging",",","adding","of","penalty","terms",",","etc",".","You","can","optionally","provide","an","output_types","argument",",","which","describes","how","to","interpret","the","model","'s","outputs",".","This","should","be","a","list","of","strings",",","one","for","each","output",".","You","can","use","an","arbitrary","output_type","for","a","output",",","but","some","output_types","are","special","and","will","undergo","extra","processing",":","-","'prediction","'",":","This","is","a","normal","output",",","and","will","be","returned","by","predict","(",")",".","If","output","types","are","not","specified",",","all","outputs","are","assumed","to","be","of","this","type",".","-","'loss","'",":","This","output","will","be","used","in","place","of","the","normal","outputs","for","computing","the","loss","function",".","For","example",",","models","that","output","probability","distributions","usually","do","it","by","computing","unbounded","numbers","(","the","logits",")",",","then","passing","them","through","a","softmax","function","to","turn","them","into","probabilities",".","When","computing","the","cross","entropy",",","it","is","more","numerically","stable","to","use","the","logits","directly","rather","than","the","probabilities",".","You","can","do","this","by","having","the","model","produce","both","probabilities","and","logits","as","outputs",",","then","specifying","output_types=","[","'prediction","'",",","'loss","'","]",".","When","predict","(",")","is","called",",","only","the","first","output","(","the","probabilities",")","will","be","returned",".","But","during","training",",","it","is","the","second","output","(","the","logits",")","that","will","be","passed","to","the","loss","function",".","-","'variance","'",":","This","output","is","used","for","estimating","the","uncertainty","in","another","output",".","To","create","a","model","that","can","estimate","uncertainty",",","there","must","be","the","same","number","of","'prediction","'","and","'variance","'","outputs",".","Each","variance","output","must","have","the","same","shape","as","the","corresponding","prediction","output",",","and","each","element","is","an","estimate","of","the","variance","in","the","corresponding","prediction",".","Also","be","aware","that","if","a","model","supports","uncertainty",",","it","MUST","use","dropout","on","every","layer",",","and","dropout","most","be","enabled","during","uncertainty","prediction",".","Otherwise",",","the","uncertainties","it","computes","will","be","inaccurate",".","-","other",":","Arbitrary","output_types","can","be","used","to","extract","outputs","produced","by","the","model",",","but","will","have","no","additional","processing","performed","."]
docstr: Generates predictions for input samples, processing samples in a batch.
  
  Parameters
  ----------
  X: ndarray
      the input data, as a Numpy array.
  transformers: list of dc.trans.Transformers
      Transformers that the input data has been transformed by.  The output
      is passed through these transformers to undo the transformations.
  
  Returns
  -------
  a NumPy array of the model produces a single output, or a list of arrays
  if it produces multiple outputs
docstr_tok: ["Generates","predictions","for","input","samples",",","processing","samples","in","a","batch",".","Parameters","--","--","--","--","--","X",":","ndarray","the","input","data",",","as","a","Numpy","array",".","transformers",":","list","of","dc.trans.Transformers","Transformers","that","the","input","data","has","been","transformed","by",".","The","output","is","passed","through","these","transformers","to","undo","the","transformations",".","Returns","--","--","--","-","a","NumPy","array","of","the","model","produces","a","single","output",",","or","a","list","of","arrays","if","it","produces","multiple","outputs"]
code: def predict_on_batch(
      self, X: np.typing.ArrayLike, transformers: List[Transformer] = []
  ) -> OneOrMany[np.ndarray]:
      """Generates predictions for input samples, processing samples in a batch.
  
      Parameters
      ----------
      X: ndarray
          the input data, as a Numpy array.
      transformers: list of dc.trans.Transformers
          Transformers that the input data has been transformed by.  The output
          is passed through these transformers to undo the transformations.
  
      Returns
      -------
      a NumPy array of the model produces a single output, or a list of arrays
      if it produces multiple outputs
      """
      dataset = NumpyDataset(X=X, y=None)
      return self.predict(dataset, transformers)
  
imports: import numpy
  import torch
  import time
  import logging
  import os
  import datetime
  from deepchem.data import Dataset, NumpyDataset
  from deepchem.metrics import Metric
  from deepchem.models.losses import Loss
  from deepchem.models.models import Model
  from deepchem.models.optimizers import Adam, Optimizer, LearningRateSchedule
  from deepchem.trans import Transformer, undo_transforms
  from deepchem.utils.evaluate import GeneratorEvaluator
  from collections.abc import Sequence
  from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple, Union
  from deepchem.utils.typing import LossFn, OneOrMany
  from deepchem.models.wandblogger import WandbLogger
label_desc: Use image node_id 8 for calling the TorchModel obj's underlying member method code with example usage: obj.predict_on_batch(X, transformers) and returns: self