def reduce_metrics(cls, logging_outputs) -> None:
        """Aggregate logging outputs from data parallel training."""
        loss_sum = sum(log.get("loss", 0) for log in logging_outputs)
        l1_loss_sum = sum(log.get("l1_loss", 0) for log in logging_outputs)
        l2_loss_sum = sum(log.get("l2_loss", 0) for log in logging_outputs)
        bce_loss_sum = sum(log.get("bce_loss", 0) for log in logging_outputs)
        sample_size = max(1, sum(log.get("sample_size", 0) for log in logging_outputs))
        metrics.log_scalar(
            "loss", loss_sum / sample_size, sample_size, 1, round=5
        )
        encoder_alpha_sum = sum(log.get("encoder_alpha", 0) for log in logging_outputs)
        decoder_alpha_sum = sum(log.get("decoder_alpha", 0) for log in logging_outputs)
        ngpu = sum(log.get("ngpu", 0) for log in logging_outputs)

        metrics.log_scalar(
            "l1_loss", l1_loss_sum / sample_size, sample_size, 2, round=5
        )
        metrics.log_scalar(
            "l2_loss", l2_loss_sum / sample_size, sample_size, 2, round=5
        )
        metrics.log_scalar(
            "bce_loss", bce_loss_sum / sample_size, sample_size, 2, round=5
        )
        metrics.log_scalar(
            "encoder_alpha", encoder_alpha_sum / sample_size, sample_size, round=5
        )
        metrics.log_scalar(
            "decoder_alpha", decoder_alpha_sum / sample_size, sample_size, round=5
        )

        if "enc_dec_attn_loss" in logging_outputs[0]:
            enc_dec_attn_loss_sum = sum(log.get("enc_dec_attn_loss", 0) for log in logging_outputs)
            metrics.log_scalar(
                "enc_dec_attn_loss", enc_dec_attn_loss_sum / sample_size, sample_size, round=8
            )
Aggregate logging outputs from data parallel training.
speecht5/speecht5/criterions/text_to_speech_loss.py