class_docstr: The implements the loss function for models that use a dc.models.losses.Loss.
class_docstr_tok: ["The","implements","the","loss","function","for","models","that","use","a","dc.models.losses.Loss","."]
code: def __call__(
      self, outputs: List, labels: List, weights: List
  ) -> float:
      if len(outputs) != 1 or len(labels) != 1 or len(weights) != 1:
          raise ValueError(
              "Loss functions expects exactly one each of outputs, labels, and weights"
          )
      losses = self.criterion(outputs[0], labels[0])
      w = weights[0]
      if len(w.shape) < len(losses.shape):
          if isinstance(w, torch.Tensor):
              shape = tuple(w.shape)
          else:
              shape = w.shape
          shape = tuple(-1 if x is None else x for x in shape)
          w = w.reshape(
              shape + (1,) * (len(losses.shape) - len(w.shape))
          )
  
      loss = losses * w
      loss = loss.mean()
      if self.model.regularization_loss is not None:
          loss += self.model.regularization_loss()
      return loss
  
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 2 for calling the _StandardLoss obj's underlying member method code with example usage: obj.__call__(outputs, labels, weights) and returns: loss