def forward(self, model, sample):
        """Compute the loss for the given sample.

        Returns a tuple with three elements:
        1) the loss
        2) the sample size, which is used as the denominator for the gradient
        3) logging outputs to display while training
        """
        net_output = model(**sample["net_input"])
        loss, l1_loss, l2_loss, bce_loss, enc_dec_attn_loss = self.compute_loss(model, net_output, sample)
        # sample_size = (
        #     sample["target"].size(0) if self.sentence_avg else sample["nframes"]
        # )
        sample_size = 1
        logging_output = {
            "loss": loss.item(),
            "l1_loss": l1_loss.item(),
            "l2_loss": l2_loss.item(),
            "bce_loss": bce_loss.item(),
            "sample_size": 1,
            "ntokens": sample["ntokens"],
            "nsentences": sample["target"].size(0),
        }

        if enc_dec_attn_loss is not None:
            logging_output['enc_dec_attn_loss'] = enc_dec_attn_loss.item()

        if hasattr(model, 'text_encoder_prenet'):
            logging_output["encoder_alpha"] = model.text_encoder_prenet.encoder_prenet[-1].alpha.item()
            logging_output["decoder_alpha"] = model.speech_decoder_prenet.decoder_prenet[-1].alpha.item()
        elif hasattr(model, "speech_encoder_prenet"):
            logging_output["decoder_alpha"] = model.speech_decoder_prenet.decoder_prenet[-1].alpha.item()
        else:
            if 'task' not in sample:
                logging_output["encoder_alpha"] = model.encoder_prenet.encoder_prenet[-1].alpha.item()
            logging_output["decoder_alpha"] = model.decoder_prenet.decoder_prenet[-1].alpha.item()

        return loss, sample_size, logging_output
Compute the loss for the given sample.

        Returns a tuple with three elements:
        1) the loss
        2) the sample size, which is used as the denominator for the gradient
        3) logging outputs to display while training
        
speecht5/speecht5/criterions/text_to_speech_loss.py