    def forward(
        self,
        input_ids,
        input_mask,
        output_ids,
        output_mask,
        mels=None,
        mels_mask=None,
    ):
        """
        Args:
            input_ids: [B, T1]
            input_mask: [B, T1]
            output_ids: [B, T2]
            output_mask: [B, T2]
            mels: [B, T, n_mels] if is not None
            mels_mask: [B, T] if is not None
        """
        # [B, T1+2]
        input_ids, input_mask, input_label = self.padding_for_input(
            input_ids,
            input_mask,
            self.input_eos_token_id,
            self.input_bos_token_id,
            self.pad_token_id,
        )
        # [B, T2+2]
        output_ids, output_mask, output_label = self.padding_for_output(
            output_ids,
            output_mask,
            self.output_eos_token_id,
            self.output_bos_token_id,
            self.pad_token_id,
        )

        if self.use_global_style_encoder:
            # [B, T1+2, D]
            input_emb = self.model.model.embed_tokens(input_ids)
            # [B, T2+2, D]
            output_emb = self.model.model.embed_tokens(output_ids)
            # [B, D] -> [B, 1, D]
            global_style_emb = self.global_encoder(mels, mels_mask).unsqueeze(1)

            # [B, T1+T2+5, D]
            llama_input_emb = torch.cat(
                [input_emb, global_style_emb, output_emb], dim=1
            )
            # [B, T1+T2+5]
            llama_attention_mask = torch.cat(
                [
                    input_mask,
                    torch.as_tensor([1], device=input_mask.device).expand(
                        llama_input_emb.size(0), 1
                    ),  # [B, 1]
                    output_mask,
                ],
                dim=-1,
            )
            # [B, T1+T2+5]
            llama_label = torch.cat(
                [
                    input_label,
                    torch.as_tensor(
                        [self.no_loss_label], device=input_label.device
                    ).expand(
                        llama_input_emb.size(0), 1
                    ),  # [B, 1]
                    output_label,
                ],
                dim=-1,
            )

            out = self.model(
                inputs_embeds=llama_input_emb,
                attention_mask=llama_attention_mask,
                labels=llama_label,
                return_dict=True,
            )
        else:
            # [B, T1+T2+4]
            llama_input_ids = torch.cat([input_ids, output_ids], dim=-1)
            llama_attention_mask = torch.cat([input_mask, output_mask], dim=-1)
            llama_label = torch.cat([input_label, output_label], dim=-1)

            out = self.model(
                llama_input_ids,
                attention_mask=llama_attention_mask,
                labels=llama_label,
                return_dict=True,
            )

        return out
Args:
input_ids: [B, T1]
input_mask: [B, T1]
output_ids: [B, T2]
output_mask: [B, T2]
mels: [B, T, n_mels] if is not None
mels_mask: [B, T] if is not None
models/vc/autoregressive_transformer/ar_model.py