templates/adding_a_new_model/cookiecutter-template-{{cookiecutter.modelname}}/modeling_tf_{{cookiecutter.lowercase_modelname}}.py/compute_combined_attns_mask
    def compute_combined_attns_mask(self, inputs, input_shape, past_key_values_length):
        # [bsz, seq_len] -> [bsz, 1, tgt_seq_len, src_seq_len]
        combined_attention_mask = None
        if input_shape[-1] > 1:
            combined_attention_mask = _make_causal_mask(input_shape, past_key_values_length=past_key_values_length)
        else:
            combined_attention_mask = _expand_mask(
                tf.ones((input_shape[0], input_shape[1] + past_key_values_length)), tgt_len=input_shape[-1]
            )

        if inputs["attention_mask"] is None and inputs["input_ids"] is not None and input_shape[-1] > 1:
            attention_mask = tf.cast(
                tf.math.not_equal(inputs["input_ids"], self.config.pad_token_id), inputs["input_ids"].dtype
            )
            attention_mask = tf.concat(
                [
                    tf.ones((input_shape[0], past_key_values_length), dtype=attention_mask.dtype),
                    attention_mask,
                ],
                axis=-1,
            )
        else:
            attention_mask = tf.ones((input_shape[0], input_shape[1] + past_key_values_length))

        return attention_mask, combined_attention_mask