docstr: Aggregate logging outputs from data parallel training.
docstr_tok: ["Aggregate","logging","outputs","from","data","parallel","training","."]
code: def aggregate_logging_outputs(logging_outputs):
      """Aggregate logging outputs from data parallel training."""
      loss_sum = sum(log.get("loss", 0) for log in logging_outputs)
      ntokens = sum(log.get("ntokens", 0) for log in logging_outputs)
      nsentences = sum(
          log.get("nsentences", 0) for log in logging_outputs
      )
      sample_size = sum(
          log.get("sample_size", 0) for log in logging_outputs
      )
      agg_output = {
          "loss": loss_sum / nsentences,
          "ntokens": ntokens,
          "nsentences": nsentences,
          "sample_size": sample_size,
      }
      return agg_output
  
file_path: fairseq/examples/speech_recognition/criterions/ASG_loss.py
imports: import torch
  from examples.speech_recognition.data.replabels import pack_replabels
  from fairseq import utils
  from fairseq.criterions import FairseqCriterion, register_criterion
label_desc: Use image node_id 7 for calling the ASGCriterion obj's underlying member method code with example usage: obj.aggregate_logging_outputs(logging_outputs) and returns: agg_output