    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)
Aggregate logging outputs from data parallel training.
fairseq/criterions/speech_ulm_criterion.py