docstr: Aggregate logging outputs from data parallel training.
docstr_tok: ["Aggregate","logging","outputs","from","data","parallel","training","."]
code: def reduce_metrics(cls, logging_outputs) -> None:
      """Aggregate logging outputs from data parallel training."""
      super().reduce_metrics(logging_outputs)
  
      sample_size = sum(
          log.get("sample_size", 0) for log in logging_outputs
      )
  
      rdrop_kl_loss = utils.item(
          sum(log.get("rdrop_kl_loss", 0) for log in logging_outputs)
          / sample_size
          / math.log(2)
      )
      if rdrop_kl_loss > 0:
          metrics.log_scalar("rdrop_kl_loss", rdrop_kl_loss)
  
file_path: fairseq/fairseq/criterions/label_smoothed_cross_entropy_with_rdrop.py
imports: import math
  from dataclasses import dataclass, field
  import torch
  from fairseq import utils
  from fairseq.logging import metrics
  from fairseq.criterions import register_criterion
  from fairseq.criterions.label_smoothed_cross_entropy import LabelSmoothedCrossEntropyCriterion, LabelSmoothedCrossEntropyCriterionConfig, label_smoothed_nll_loss
label_desc: Use image node_id 5 for calling the RdropLabelSmoothedCrossEntropyCriterion obj's underlying member method code with example usage: obj.reduce_metrics(cls, logging_outputs) without return types