src/transformers/models/marian/modeling_tf_marian.py/TFMarianMTModel/adjust_logits_during_generation
class TFMarianMTModel:    def adjust_logits_during_generation(
        self, logits, cur_len, max_length, forced_bos_token_id, forced_eos_token_id, **kwargs
    ):
        """Never predict pad_token_id. Predict </s> when max_length is reached."""
        vocab_range = tf.constant(range(self.config.vocab_size))
        logits = tf.where(vocab_range == self.config.pad_token_id, LARGE_NEGATIVE, logits)
        if cur_len == 1 and forced_bos_token_id is not None:
            vocab_range = tf.constant(range(self.config.vocab_size))
            return tf.where(vocab_range != forced_bos_token_id, LARGE_NEGATIVE, logits)
        elif cur_len == max_length - 1 and forced_eos_token_id is not None:
            vocab_range = tf.constant(range(self.config.vocab_size))
            return tf.where(vocab_range != forced_eos_token_id, LARGE_NEGATIVE, logits)
        else:
            return logits