code: def add_training_cost(self, outputs, labels, weights):
      weighted_costs = []  # weighted costs for each example
      for task in range(self.n_tasks):
          weighted_cost = self.cost(
              outputs[task], labels[:, task], weights[:, task]
          )
          weighted_costs.append(weighted_cost)
      loss = torch.cat(weighted_costs).sum()
      # weight decay
      if self.penalty > 0.0:
          for variable in self.regularizaed_variables:
              loss += self.penalty * 0.5 * variable.mul(variable).sum()
      return loss
  
file_path: deepchem/contrib/torch/torch_model.py
imports: import torch
  import time
  import numpy
  from deepchem.trans import undo_transforms
  from deepchem.utils.save import log
  from deepchem.models import Model
label_desc: Use image node_id 2 for calling the TorchMultitaskModel obj's underlying member method code with example usage: obj.add_training_cost(outputs, labels, weights) and returns: loss