class_docstr: A class containing all functions for auto-regressive text generation, to be used as a mixin in [`PreTrainedModel`].
  
  The class exposes [`~generation.GenerationMixin.generate`], which can be used for:
      - *greedy decoding* by calling [`~generation.GenerationMixin.greedy_search`] if `num_beams=1` and
        `do_sample=False`
      - *contrastive search* by calling [`~generation.GenerationMixin.contrastive_search`] if `penalty_alpha>0` and
        `top_k>1`
      - *multinomial sampling* by calling [`~generation.GenerationMixin.sample`] if `num_beams=1` and
        `do_sample=True`
      - *beam-search decoding* by calling [`~generation.GenerationMixin.beam_search`] if `num_beams>1` and
        `do_sample=False`
      - *beam-search multinomial sampling* by calling [`~generation.GenerationMixin.beam_sample`] if `num_beams>1`
        and `do_sample=True`
      - *diverse beam-search decoding* by calling [`~generation.GenerationMixin.group_beam_search`], if `num_beams>1`
        and `num_beam_groups>1`
      - *constrained beam-search decoding* by calling [`~generation.GenerationMixin.constrained_beam_search`], if
        `constraints!=None` or `force_words_ids!=None`
  
  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","functions","for","auto-regressive","text","generation",",","to","be","used","as","a","mixin","in","[","`","PreTrainedModel","`","]",".","The","class","exposes","[","`","~generation.GenerationMixin.generate","`","]",",","which","can","be","used","for",":","-","*","greedy","decoding","*","by","calling","[","`","~generation.GenerationMixin.greedy_search","`","]","if","`","num_beams=1","`","and","`","do_sample=False","`","-","*","contrastive","search","*","by","calling","[","`","~generation.GenerationMixin.contrastive_search","`","]","if","`","penalty_alpha",">","0","`","and","`","top_k",">","1","`","-","*","multinomial","sampling","*","by","calling","[","`","~generation.GenerationMixin.sample","`","]","if","`","num_beams=1","`","and","`","do_sample=True","`","-","*","beam-search","decoding","*","by","calling","[","`","~generation.GenerationMixin.beam_search","`","]","if","`","num_beams",">","1","`","and","`","do_sample=False","`","-","*","beam-search","multinomial","sampling","*","by","calling","[","`","~generation.GenerationMixin.beam_sample","`","]","if","`","num_beams",">","1","`","and","`","do_sample=True","`","-","*","diverse","beam-search","decoding","*","by","calling","[","`","~generation.GenerationMixin.group_beam_search","`","]",",","if","`","num_beams",">","1","`","and","`","num_beam_groups",">","1","`","-","*","constrained","beam-search","decoding","*","by","calling","[","`","~generation.GenerationMixin.constrained_beam_search","`","]",",","if","`","constraints","!","=None","`","or","`","force_words_ids","!","=None","`","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 [`LogitsProcessorList`] list object that contains all relevant [`LogitsProcessor`]
  instances used to modify the scores of the language model head.
docstr_tok: ["This","class","returns","a","[","`","LogitsProcessorList","`","]","list","object","that","contains","all","relevant","[","`","LogitsProcessor","`","]","instances","used","to","modify","the","scores","of","the","language","model","head","."]
code: def _get_logits_processor(
      self,
      generation_config: GenerationConfig,
      input_ids_seq_length: int,
      encoder_input_ids: torch.LongTensor,
      prefix_allowed_tokens_fn: Callable[
          [int, torch.Tensor], List[int]
      ],
      logits_processor: Optional[LogitsProcessorList],
      model_kwargs: Optional[Dict[str, Any]] = None,
      negative_prompt_ids: Optional[torch.Tensor] = None,
      negative_prompt_attention_mask: Optional[torch.Tensor] = None,
  ) -> LogitsProcessorList:
      """
      This class returns a [`LogitsProcessorList`] list object that contains all relevant [`LogitsProcessor`]
      instances used to modify the scores of the language model head.
      """
      # instantiate processors list
      processors = LogitsProcessorList()
  
      if (
          generation_config.guidance_scale is not None
          and generation_config.guidance_scale != 1
      ):
          processors.append(
              UnbatchedClassifierFreeGuidanceLogitsProcessor(
                  generation_config.guidance_scale,
                  self,
                  unconditional_ids=negative_prompt_ids,
                  unconditional_attention_mask=negative_prompt_attention_mask,
                  use_cache=model_kwargs["use_cache"],
              )
          )
      if generation_config.sequence_bias is not None:
          processors.append(
              SequenceBiasLogitsProcessor(
                  sequence_bias=generation_config.sequence_bias
              )
          )
  
      if (
          generation_config.diversity_penalty is not None
          and generation_config.diversity_penalty > 0.0
      ):
          processors.append(
              HammingDiversityLogitsProcessor(
                  diversity_penalty=generation_config.diversity_penalty,
                  num_beams=generation_config.num_beams,
                  num_beam_groups=generation_config.num_beam_groups,
              )
          )
      if (
          generation_config.encoder_repetition_penalty is not None
          and generation_config.encoder_repetition_penalty != 1.0
      ):
          processors.append(
              EncoderRepetitionPenaltyLogitsProcessor(
                  penalty=generation_config.encoder_repetition_penalty,
                  encoder_input_ids=encoder_input_ids,
              )
          )
      if (
          generation_config.repetition_penalty is not None
          and generation_config.repetition_penalty != 1.0
      ):
          processors.append(
              RepetitionPenaltyLogitsProcessor(
                  penalty=generation_config.repetition_penalty
              )
          )
      if (
          generation_config.no_repeat_ngram_size is not None
          and generation_config.no_repeat_ngram_size > 0
      ):
          processors.append(
              NoRepeatNGramLogitsProcessor(
                  generation_config.no_repeat_ngram_size
              )
          )
      if (
          generation_config.encoder_no_repeat_ngram_size is not None
          and generation_config.encoder_no_repeat_ngram_size > 0
      ):
          processors.append(
              EncoderNoRepeatNGramLogitsProcessor(
                  generation_config.encoder_no_repeat_ngram_size,
                  encoder_input_ids,
              )
          )
      if generation_config.bad_words_ids is not None:
          processors.append(
              NoBadWordsLogitsProcessor(
                  generation_config.bad_words_ids,
                  generation_config.eos_token_id,
              )
          )
      if (
          generation_config.min_length is not None
          and generation_config.eos_token_id is not None
          and generation_config.min_length > 0
      ):
          processors.append(
              MinLengthLogitsProcessor(
                  generation_config.min_length,
                  generation_config.eos_token_id,
              )
          )
      if (
          generation_config.min_new_tokens is not None
          and generation_config.eos_token_id is not None
          and generation_config.min_new_tokens > 0
      ):
          processors.append(
              MinNewTokensLengthLogitsProcessor(
                  input_ids_seq_length,
                  generation_config.min_new_tokens,
                  generation_config.eos_token_id,
              )
          )
      if prefix_allowed_tokens_fn is not None:
          processors.append(
              PrefixConstrainedLogitsProcessor(
                  prefix_allowed_tokens_fn,
                  generation_config.num_beams
                  // generation_config.num_beam_groups,
              )
          )
      if generation_config.forced_bos_token_id is not None:
          processors.append(
              ForcedBOSTokenLogitsProcessor(
                  generation_config.forced_bos_token_id
              )
          )
      if generation_config.forced_eos_token_id is not None:
          processors.append(
              ForcedEOSTokenLogitsProcessor(
                  generation_config.max_length,
                  generation_config.forced_eos_token_id,
              )
          )
      if generation_config.remove_invalid_values is True:
          processors.append(InfNanRemoveLogitsProcessor())
      if generation_config.exponential_decay_length_penalty is not None:
          processors.append(
              ExponentialDecayLengthPenalty(
                  generation_config.exponential_decay_length_penalty,
                  generation_config.eos_token_id,
                  input_ids_seq_length,
              )
          )
      if generation_config.suppress_tokens is not None:
          processors.append(
              SuppressTokensLogitsProcessor(
                  generation_config.suppress_tokens
              )
          )
      if generation_config.begin_suppress_tokens is not None:
          begin_index = input_ids_seq_length
          begin_index = (
              begin_index
              if (
                  input_ids_seq_length > 1
                  or generation_config.forced_bos_token_id is None
              )
              else begin_index + 1
          )
          if generation_config.forced_decoder_ids is not None:
              # generation starts after the last token that is forced
              begin_index += generation_config.forced_decoder_ids[-1][0]
          processors.append(
              SuppressTokensAtBeginLogitsProcessor(
                  generation_config.begin_suppress_tokens, begin_index
              )
          )
      if generation_config.forced_decoder_ids is not None:
          processors.append(
              ForceTokensLogitsProcessor(
                  generation_config.forced_decoder_ids
              )
          )
      processors = self._merge_criteria_processor_list(
          processors, logits_processor
      )
      # `LogitNormalization` should always be the last logit processor, when present
      if generation_config.renormalize_logits is True:
          processors.append(LogitNormalization())
      return processors
  
imports: import copy
  import inspect
  import warnings
  from dataclasses import dataclass
  from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Tuple, Union
  import torch
  import torch.distributed
  from torch import nn
  from ..cache_utils import Cache, DynamicCache
  from ..integrations.deepspeed import is_deepspeed_zero3_enabled
  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 ..utils import ExplicitEnum, ModelOutput, is_accelerate_available, logging
  from .beam_constraints import DisjunctiveConstraint, PhrasalConstraint
  from .beam_search import BeamScorer, BeamSearchScorer, ConstrainedBeamSearchScorer
  from .candidate_generator import AssistedCandidateGenerator, CandidateGenerator, PromptLookupCandidateGenerator, _crop_past_key_values, _prepare_attention_mask, _prepare_token_type_ids
  from .configuration_utils import GenerationConfig
  from .logits_process import EncoderNoRepeatNGramLogitsProcessor, EncoderRepetitionPenaltyLogitsProcessor, EpsilonLogitsWarper, EtaLogitsWarper, ExponentialDecayLengthPenalty, ForcedBOSTokenLogitsProcessor, ForcedEOSTokenLogitsProcessor, ForceTokensLogitsProcessor, HammingDiversityLogitsProcessor, InfNanRemoveLogitsProcessor, LogitNormalization, LogitsProcessorList, MinLengthLogitsProcessor, MinNewTokensLengthLogitsProcessor, NoBadWordsLogitsProcessor, NoRepeatNGramLogitsProcessor, PrefixConstrainedLogitsProcessor, RepetitionPenaltyLogitsProcessor, SequenceBiasLogitsProcessor, SuppressTokensAtBeginLogitsProcessor, SuppressTokensLogitsProcessor, TemperatureLogitsWarper, TopKLogitsWarper, TopPLogitsWarper, TypicalLogitsWarper, UnbatchedClassifierFreeGuidanceLogitsProcessor
  from .stopping_criteria import MaxLengthCriteria, MaxTimeCriteria, StoppingCriteria, StoppingCriteriaList, validate_stopping_criteria
label_desc: Use image node_id 15 for calling the GenerationMixin obj's underlying member method code with example usage: obj._get_logits_processor(generation_config, input_ids_seq_length, encoder_input_ids, prefix_allowed_tokens_fn, logits_processor, model_kwargs, negative_prompt_ids, negative_prompt_attention_mask) and returns: processors