class_docstr: This is a composite loss that, given a list of model outputs and a list of targets,
  computes an average of losses for each output-target pair
code: def build_criterion(cls, args, task):
      underlying_criterion = CompositeLoss.build_underlying_criterion(
          args, task
      )
  
      class FakeModel(nn.Module):
          def __init__(self, model, net_out, target):
              super().__init__()
              self.model = model
              self.net_out = net_out
              self.target = target
  
          def forward(self, **unused):
              return self.net_out
  
          def get_normalized_probs(
              self, net_output, log_probs, sample=None
          ):
              return self.model.get_normalized_probs(
                  net_output, log_probs, sample=sample
              )
  
          def get_targets(self, *unused):
              return self.target
  
          @property
          def decoder(self):
              return self.model.decoder
  
      class _CompositeLoss(LegacyFairseqCriterion):
          def __init__(self, args, task, underlying_criterion):
              super().__init__(args, task)
              self.underlying_criterion = underlying_criterion
  
          def forward(self, model, sample, reduce=True):
              net_outputs = model(**sample["net_input"])
              targets = sample["target"]
  
              bsz = targets[0].size(0)
              loss = (
                  net_outputs[0][0]
                  .new(1 if reduce else bsz)
                  .float()
                  .zero_()
              )
  
              sample_size = 0
              logging_output = {}
              for o, t in zip(net_outputs[0], targets):
                  m = FakeModel(model, (o, net_outputs[1]), t)
                  sample["target"] = t
                  l, ss, logging_output = self.underlying_criterion(
                      m, sample, reduce
                  )
                  loss += l
                  sample_size += ss
  
              loss.div_(len(targets))
              sample_size /= len(targets)
  
              logging_output["loss"] = (
                  utils.item(loss.data) if reduce else loss.data
              )
              return loss, sample_size, logging_output
  
          @staticmethod
          def aggregate_logging_outputs(logging_outputs):
              return underlying_criterion.__class__.aggregate_logging_outputs(
                  logging_outputs
              )
  
          @staticmethod
          def reduce_metrics(logging_outputs) -> None:
              underlying_criterion.__class__.reduce_metrics(
                  logging_outputs
              )
  
      return _CompositeLoss(args, task, underlying_criterion)
  
file_path: fairseq/fairseq/criterions/composite_loss.py
imports: from fairseq import utils
  from fairseq.criterions import LegacyFairseqCriterion, register_criterion
  from torch import nn
label_desc: Use image node_id 4 for calling the CompositeLoss obj's underlying member method code with example usage: obj.build_criterion(cls, args, task) and returns: _CompositeLoss, self, self, self, self, loss,  sample_size,  logging_output, underlying_criterion