class_docstr: A class containing all of the functions supporting generation, to be used as a mixin in [`TFPreTrainedModel`].
  
  The class exposes [`~generation.TFGenerationMixin.generate`], which can be used for:
      - *greedy decoding* by calling [`~generation.TFGenerationMixin.greedy_search`] if `num_beams=1` and
        `do_sample=False`
      - *contrastive search* by calling [`~generation.TFGenerationMixin.contrastive_search`] if `penalty_alpha>0` and
        `top_k>1`
      - *multinomial sampling* by calling [`~generation.TFGenerationMixin.sample`] if `num_beams=1` and
        `do_sample=True`
      - *beam-search decoding* by calling [`~generation.TFGenerationMixin.beam_search`] if `num_beams>1`
  
  You do not need to call any of the above methods directly. Pass custom parameter values to 'generate' instead. To
  learn more about decoding strategies refer to the [text generation strategies guide](../generation_strategies).
class_docstr_tok: ["A","class","containing","all","of","the","functions","supporting","generation",",","to","be","used","as","a","mixin","in","[","`","TFPreTrainedModel","`","]",".","The","class","exposes","[","`","~generation.TFGenerationMixin.generate","`","]",",","which","can","be","used","for",":","-","*","greedy","decoding","*","by","calling","[","`","~generation.TFGenerationMixin.greedy_search","`","]","if","`","num_beams=1","`","and","`","do_sample=False","`","-","*","contrastive","search","*","by","calling","[","`","~generation.TFGenerationMixin.contrastive_search","`","]","if","`","penalty_alpha",">","0","`","and","`","top_k",">","1","`","-","*","multinomial","sampling","*","by","calling","[","`","~generation.TFGenerationMixin.sample","`","]","if","`","num_beams=1","`","and","`","do_sample=True","`","-","*","beam-search","decoding","*","by","calling","[","`","~generation.TFGenerationMixin.beam_search","`","]","if","`","num_beams",">","1","`","You","do","not","need","to","call","any","of","the","above","methods","directly",".","Pass","custom","parameter","values","to","'generate","'","instead",".","To","learn","more","about","decoding","strategies","refer","to","the","[","text","generation","strategies","guide","]","(","..","\/generation_strategies",")","."]
docstr: This class returns a [`TFLogitsProcessorList`] list object that contains all relevant [`TFLogitsWarper`]
  instances used for multinomial sampling.
code: def _get_logits_warper(
      self,
      generation_config: GenerationConfig,
  ) -> TFLogitsProcessorList:
      """
      This class returns a [`TFLogitsProcessorList`] list object that contains all relevant [`TFLogitsWarper`]
      instances used for multinomial sampling.
      """
  
      # instantiate warpers list
      warpers = TFLogitsProcessorList()
  
      # In beam methods, we need to keep at least one non-eos token to explore continuations that might have a
      # better score (i.e. keep len(generation_config.eos_token_id) + 1)
      if generation_config.num_beams > 1:
          if isinstance(generation_config.eos_token_id, list):
              min_tokens_to_keep = (
                  len(generation_config.eos_token_id) + 1
              )
          else:
              min_tokens_to_keep = 2
      else:
          min_tokens_to_keep = 1
  
      if (
          generation_config.temperature is not None
          and generation_config.temperature != 1.0
      ):
          warpers.append(
              TFTemperatureLogitsWarper(generation_config.temperature)
          )
      if (
          generation_config.top_k is not None
          and generation_config.top_k != 0
      ):
          warpers.append(
              TFTopKLogitsWarper(
                  top_k=generation_config.top_k,
                  min_tokens_to_keep=min_tokens_to_keep,
              )
          )
      if (
          generation_config.top_p is not None
          and generation_config.top_p < 1.0
      ):
          warpers.append(
              TFTopPLogitsWarper(
                  top_p=generation_config.top_p,
                  min_tokens_to_keep=min_tokens_to_keep,
              )
          )
      return warpers
  
imports: import copy
  import inspect
  import warnings
  from dataclasses import dataclass
  from typing import Any, Dict, Optional, Tuple, Union
  import numpy
  import tensorflow
  from tensorflow.compiler.tf2xla.python.xla import dynamic_update_slice
  from ..modeling_tf_outputs import TFCausalLMOutputWithPast, TFSeq2SeqLMOutput
  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
  from .configuration_utils import GenerationConfig
  from .tf_logits_process import TFForcedBOSTokenLogitsProcessor, TFForcedEOSTokenLogitsProcessor, TFForceTokensLogitsProcessor, TFLogitsProcessorList, TFMinLengthLogitsProcessor, TFNoBadWordsLogitsProcessor, TFNoRepeatNGramLogitsProcessor, TFRepetitionPenaltyLogitsProcessor, TFSuppressTokensAtBeginLogitsProcessor, TFSuppressTokensLogitsProcessor, TFTemperatureLogitsWarper, TFTopKLogitsWarper, TFTopPLogitsWarper
label_desc: Use image node_id 17 for calling the TFGenerationMixin obj's underlying member method code with example usage: obj._get_logits_warper(generation_config) and returns: warpers