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."""
      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
      )
      return {
          "student_loss": sum(
              log.get("student_loss", 0) for log in logging_outputs
          )
          / sample_size
          / math.log(2),
          "student_nll_loss": sum(
              log.get("student_nll_loss", 0) for log in logging_outputs
          )
          / ntokens
          / math.log(2),
          "teacher_loss": sum(
              log.get("teacher_loss", 0) for log in logging_outputs
          )
          / sample_size
          / math.log(2),
          "teacher_nll_loss": sum(
              log.get("teacher_nll_loss", 0) for log in logging_outputs
          )
          / ntokens
          / math.log(2),
          "loss": sum(log.get("loss", 0) for log in logging_outputs)
          / sample_size
          / math.log(2),
          "ntokens": ntokens,
          "nsentences": nsentences,
          "sample_size": sample_size,
      }
  
file_path: translate/pytorch_translate/research/knowledge_distillation/dual_decoder_kd_loss.py
imports: import math
  from fairseq import utils
  from fairseq.criterions import LegacyFairseqCriterion, register_criterion
label_desc: Use image node_id 6 for calling the DualDecoderCriterion obj's underlying member method code with example usage: obj.aggregate_logging_outputs(logging_outputs) and returns: dict