    def add_phone_eos_bos_label(
        self, phone_ids, phone_mask, phone_eos_id, phone_bos_id, pad_token_id, label
    ):
        # phone_ids: [B, T]
        # phone_mask: [B, T]

        # add 0 in the left
        lang_mask = F.pad(phone_mask, (1, 0), value=0)
        # add 0 in the right
        lang_mask = F.pad(lang_mask, (0, 1), value=0)

        if label == "phone_id":
            phone_ids = phone_ids + self.target_vocab_size * phone_mask

        phone_ids = phone_ids * phone_mask
        """Step-by-Step Computation:

            Pad phone_ids:

            After padding: [[101, 102, 103, 0]]
            Invert and Pad phone_mask:

            Inverted mask: [[0, 0, 0]]
            Padded inverted mask: [[0, 0, 0, 1]]
            Calculate EOS Insertion:

            Multiply with phone_eos_id: [[0, 0, 0, 200]]
            Combine:

            Combined result: [[101, 102, 103, 200]]
        """
        phone_ids = F.pad(phone_ids, (0, 1), value=0) + phone_eos_id * F.pad(
            1 - phone_mask, (0, 1), value=1
        )  # make pad token eos token, add eos token at the end
        phone_mask = F.pad(phone_mask, (1, 0), value=1)  # add eos mask
        phone_ids = phone_ids * phone_mask + pad_token_id * (
            1 - phone_mask
        )  # restore pad token ids
        phone_ids = F.pad(phone_ids, (1, 0), value=phone_bos_id)  # add bos token
        phone_mask = F.pad(phone_mask, (1, 0), value=1)  # add bos mask
        phone_label = -100 * torch.ones_like(
            phone_ids
        )  # loss for entire phone is not computed (passed to llama)
        return phone_ids, phone_mask, phone_label, lang_mask
Step-by-Step Computation:

Pad phone_ids:

After padding: [[101, 102, 103, 0]]
Invert and Pad phone_mask:

Inverted mask: [[0, 0, 0]]
Padded inverted mask: [[0, 0, 0, 1]]
Calculate EOS Insertion:

Multiply with phone_eos_id: [[0, 0, 0, 200]]
Combine:

Combined result: [[101, 102, 103, 200]]
models/tts/debatts/t2s_model.py