docstr: Aggregate logging outputs from data parallel training.
docstr_tok: ["Aggregate","logging","outputs","from","data","parallel","training","."]
code: def reduce_metrics(logging_outputs) -> None:
      """Aggregate logging outputs from data parallel training."""
      loss_sum = sum(log.get("loss", 0) for log in logging_outputs)
      token_loss_sum = sum(
          log.get("token_loss", 0) for log in logging_outputs
      )
      dur_loss_sum = sum(
          log.get("dur_loss", 0) for log in logging_outputs
      )
      f0_loss_sum = sum(
          log.get("f0_loss", 0) for log in logging_outputs
      )
  
      sample_size = sum(
          log.get("sample_size", 0) for log in logging_outputs
      )
  
      metrics.log_scalar(
          "loss", loss_sum / sample_size, sample_size, round=3
      )
  
      metrics.log_scalar(
          "token_loss",
          token_loss_sum / sample_size,
          sample_size,
          round=3,
      )
  
      metrics.log_scalar(
          "dur_loss", dur_loss_sum / sample_size, sample_size, round=3
      )
  
      metrics.log_scalar(
          "f0_loss", f0_loss_sum / sample_size, sample_size, round=3
      )
  
file_path: fairseq/fairseq/criterions/speech_ulm_criterion.py
imports: import torch
  from dataclasses import dataclass, field
  import torch.nn.functional
  from fairseq.logging import metrics
  from fairseq.tasks import FairseqTask
  from fairseq.criterions import FairseqCriterion, register_criterion
  from fairseq.dataclass import FairseqDataclass
  from omegaconf import II
label_desc: Use image node_id 3 for calling the SpeechUnitLmCriterion obj's underlying member method code with example usage: obj.reduce_metrics(logging_outputs) without return types