class_docstr: A class containing all of the functions supporting generation, to be used as a mixin in [`TFPreTrainedModel`].
class_docstr_tok: ["A","class","containing","all","of","the","functions","supporting","generation",",","to","be","used","as","a","mixin","in","[","`","TFPreTrainedModel","`","]","."]
docstr: Implement in subclasses of [`PreTrainedModel`] for custom behavior to adjust the logits in the generate method.
code: def adjust_logits_during_generation(
      self,
      logits,
      cur_len,
      max_length,
      forced_bos_token_id,
      forced_eos_token_id,
      **kwargs,
  ):
      """
      Implement in subclasses of [`PreTrainedModel`] for custom behavior to adjust the logits in the generate method.
      """
      vocab_size = getattr(self.config, "vocab_size", None)
      if vocab_size is None and self.config.is_encoder_decoder:
          decoder_config = getattr(self.config, "decoder", None)
          if decoder_config is not None:
              vocab_size = getattr(
                  self.config.decoder, "vocab_size", None
              )
  
      if cur_len == 1 and forced_bos_token_id is not None:
          vocab_range = tf.constant(range(vocab_size))
          return tf.where(
              vocab_range != forced_bos_token_id, -1e8, logits
          )
      elif (
          cur_len == max_length - 1 and forced_eos_token_id is not None
      ):
          vocab_range = tf.constant(range(vocab_size))
          return tf.where(
              vocab_range != forced_eos_token_id, -1e8, logits
          )
      else:
          return logits
  
imports: import inspect
  import warnings
  from dataclasses import dataclass
  from typing import Any, Dict, List, Optional, Tuple, Union
  import numpy
  import tensorflow
  from tensorflow.compiler.tf2xla.python.xla import dynamic_update_slice
  from .generation_tf_logits_process import TFForcedBOSTokenLogitsProcessor, TFForcedEOSTokenLogitsProcessor, TFForceTokensLogitsProcessor, TFLogitsProcessorList, TFMinLengthLogitsProcessor, TFNoBadWordsLogitsProcessor, TFNoRepeatNGramLogitsProcessor, TFRepetitionPenaltyLogitsProcessor, TFSuppressTokensAtBeginLogitsProcessor, TFSuppressTokensLogitsProcessor, TFTemperatureLogitsWarper, TFTopKLogitsWarper, TFTopPLogitsWarper
  from .models.auto import TF_MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TF_MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING, TF_MODEL_FOR_VISION_2_SEQ_MAPPING
  from .tf_utils import shape_list, stable_softmax
  from .utils import ModelOutput, logging
label_desc: Use image node_id 6 for calling the TFGenerationMixin obj's underlying member method code with example usage: obj.adjust_logits_during_generation(logits, cur_len, max_length, forced_bos_token_id, forced_eos_token_id) and returns: tf, tf, logits