class_docstr: A class containing all functions for auto-regressive text generation, to be used as a mixin in [`PreTrainedModel`].
  
  The class exposes [`~generation_utils.GenerationMixin.generate`], which can be used for:
      - *greedy decoding* by calling [`~generation_utils.GenerationMixin.greedy_search`] if `num_beams=1` and
        `do_sample=False`.
      - *contrastive search* by calling [`~generation_utils.GenerationMixin.contrastive_search`] if `penalty_alpha>0`
        and `top_k>1`
      - *multinomial sampling* by calling [`~generation_utils.GenerationMixin.sample`] if `num_beams=1` and
        `do_sample=True`.
      - *beam-search decoding* by calling [`~generation_utils.GenerationMixin.beam_search`] if `num_beams>1` and
        `do_sample=False`.
      - *beam-search multinomial sampling* by calling [`~generation_utils.GenerationMixin.beam_sample`] if
        `num_beams>1` and `do_sample=True`.
      - *diverse beam-search decoding* by calling [`~generation_utils.GenerationMixin.group_beam_search`], if
        `num_beams>1` and `num_beam_groups>1`.
      - *constrained beam-search decoding* by calling [`~generation_utils.GenerationMixin.constrained_beam_search`],
        if `constraints!=None` or `force_words_ids!=None`.
class_docstr_tok: ["A","class","containing","all","functions","for","auto-regressive","text","generation",",","to","be","used","as","a","mixin","in","[","`","PreTrainedModel","`","]",".","The","class","exposes","[","`","~generation_utils.GenerationMixin.generate","`","]",",","which","can","be","used","for",":","-","*","greedy","decoding","*","by","calling","[","`","~generation_utils.GenerationMixin.greedy_search","`","]","if","`","num_beams=1","`","and","`","do_sample=False","`",".","-","*","contrastive","search","*","by","calling","[","`","~generation_utils.GenerationMixin.contrastive_search","`","]","if","`","penalty_alpha",">","0","`","and","`","top_k",">","1","`","-","*","multinomial","sampling","*","by","calling","[","`","~generation_utils.GenerationMixin.sample","`","]","if","`","num_beams=1","`","and","`","do_sample=True","`",".","-","*","beam-search","decoding","*","by","calling","[","`","~generation_utils.GenerationMixin.beam_search","`","]","if","`","num_beams",">","1","`","and","`","do_sample=False","`",".","-","*","beam-search","multinomial","sampling","*","by","calling","[","`","~generation_utils.GenerationMixin.beam_sample","`","]","if","`","num_beams",">","1","`","and","`","do_sample=True","`",".","-","*","diverse","beam-search","decoding","*","by","calling","[","`","~generation_utils.GenerationMixin.group_beam_search","`","]",",","if","`","num_beams",">","1","`","and","`","num_beam_groups",">","1","`",".","-","*","constrained","beam-search","decoding","*","by","calling","[","`","~generation_utils.GenerationMixin.constrained_beam_search","`","]",",","if","`","constraints","!","=None","`","or","`","force_words_ids","!","=None","`","."]
docstr: This class returns a [`LogitsProcessorList`] list object that contains all relevant [`LogitsWarper`] instances
  used for multinomial sampling.
docstr_tok: ["This","class","returns","a","[","`","LogitsProcessorList","`","]","list","object","that","contains","all","relevant","[","`","LogitsWarper","`","]","instances","used","for","multinomial","sampling","."]
code: def _get_logits_warper(
      self,
      top_k: Optional[int] = None,
      top_p: Optional[float] = None,
      typical_p: Optional[float] = None,
      temperature: Optional[float] = None,
      num_beams: Optional[int] = None,
      renormalize_logits: Optional[bool] = None,
  ) -> LogitsProcessorList:
      """
      This class returns a [`LogitsProcessorList`] list object that contains all relevant [`LogitsWarper`] instances
      used for multinomial sampling.
      """
  
      # init warp parameters
      top_k = top_k if top_k is not None else self.config.top_k
      top_p = top_p if top_p is not None else self.config.top_p
      typical_p = (
          typical_p if typical_p is not None else self.config.typical_p
      )
      temperature = (
          temperature
          if temperature is not None
          else self.config.temperature
      )
      # instantiate warpers list
      warpers = LogitsProcessorList()
  
      # the following idea is largely copied from this PR: https://github.com/huggingface/transformers/pull/5420/files
      # all samplers can be found in `generation_utils_samplers.py`
      if temperature is not None and temperature != 1.0:
          warpers.append(TemperatureLogitsWarper(temperature))
      if top_k is not None and top_k != 0:
          warpers.append(
              TopKLogitsWarper(
                  top_k=top_k,
                  min_tokens_to_keep=(2 if num_beams > 1 else 1),
              )
          )
      if top_p is not None and top_p < 1.0:
          warpers.append(
              TopPLogitsWarper(
                  top_p=top_p,
                  min_tokens_to_keep=(2 if num_beams > 1 else 1),
              )
          )
      if typical_p is not None and typical_p < 1.0:
          warpers.append(
              TypicalLogitsWarper(
                  mass=typical_p,
                  min_tokens_to_keep=(2 if num_beams > 1 else 1),
              )
          )
      # `LogitNormalization` should always be the last logit processor, when present
      if renormalize_logits is True:
          warpers.append(LogitNormalization())
      return warpers
  
imports: import inspect
  import warnings
  from dataclasses import dataclass
  from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Union
  import torch
  import torch.distributed
  from torch import nn
  from flexgen.timer import timers
  from .generation_beam_constraints import Constraint, DisjunctiveConstraint, PhrasalConstraint
  from .generation_beam_search import BeamScorer, BeamSearchScorer, ConstrainedBeamSearchScorer
  from .generation_logits_process import EncoderNoRepeatNGramLogitsProcessor, ExponentialDecayLengthPenalty, ForcedBOSTokenLogitsProcessor, ForcedEOSTokenLogitsProcessor, ForceTokensLogitsProcessor, HammingDiversityLogitsProcessor, InfNanRemoveLogitsProcessor, LogitNormalization, LogitsProcessorList, MinLengthLogitsProcessor, NoBadWordsLogitsProcessor, NoRepeatNGramLogitsProcessor, PrefixConstrainedLogitsProcessor, RepetitionPenaltyLogitsProcessor, SuppressTokensAtBeginLogitsProcessor, SuppressTokensLogitsProcessor, TemperatureLogitsWarper, TopKLogitsWarper, TopPLogitsWarper, TypicalLogitsWarper
  from .generation_stopping_criteria import MaxLengthCriteria, MaxTimeCriteria, StoppingCriteria, StoppingCriteriaList, validate_stopping_criteria
  from .modeling_outputs import CausalLMOutputWithPast, Seq2SeqLMOutput
  from .models.auto import MODEL_FOR_CAUSAL_IMAGE_MODELING_MAPPING, MODEL_FOR_CAUSAL_LM_MAPPING, MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING, MODEL_FOR_VISION_2_SEQ_MAPPING
  from .pytorch_utils import torch_int_div
  from .utils import ModelOutput, logging
label_desc: Use image node_id 12 for calling the GenerationMixin obj's underlying member method code with example usage: obj._get_logits_warper(top_k, top_p, typical_p, temperature, num_beams, renormalize_logits) and returns: warpers