src/transformers/models/xglm/modeling_tf_xglm.py/TFXGLMMainLayer/_prepare_decoder_attention_mask
class TFXGLMMainLayer:    def _prepare_decoder_attention_mask(
        self,
        attention_mask: Optional[tf.Tensor],
        input_shape: tf.TensorShape,
        past_key_values_length: int,
    ) -> tf.Tensor:
        # create causal mask
        # [bsz, seq_len] -> [bsz, 1, tgt_seq_len, src_seq_len]
        combined_attention_mask: Optional[tf.Tensor] = None
        if input_shape[-1] > 1:
            combined_attention_mask = _make_causal_mask(input_shape, past_key_values_length)

        if attention_mask is not None:
            expand_attention_mask = _expand_mask(attention_mask, tgt_len=input_shape[-1])
            combined_attention_mask = (
                expand_attention_mask
                if combined_attention_mask is None
                else expand_attention_mask + combined_attention_mask
            )

        return combined_attention_mask