class_docstr: A class containing all functions for auto-regressive text generation, to be used as a mixin in
  [`FlaxPreTrainedModel`].
  
  The class exposes [`~generation_flax_utils.FlaxGenerationMixin.generate`], which can be used for:
          - *greedy decoding* by calling [`~generation_flax_utils.FlaxGenerationMixin._greedy_search`] if
            `num_beams=1` and `do_sample=False`.
          - *multinomial sampling* by calling [`~generation_flax_utils.FlaxGenerationMixin._sample`] if `num_beams=1`
            and `do_sample=True`.
          - *beam-search decoding* by calling [`~generation_utils.FlaxGenerationMixin._beam_search`] if `num_beams>1`
            and `do_sample=False`.
class_docstr_tok: ["A","class","containing","all","functions","for","auto-regressive","text","generation",",","to","be","used","as","a","mixin","in","[","`","FlaxPreTrainedModel","`","]",".","The","class","exposes","[","`","~generation_flax_utils.FlaxGenerationMixin.generate","`","]",",","which","can","be","used","for",":","-","*","greedy","decoding","*","by","calling","[","`","~generation_flax_utils.FlaxGenerationMixin._greedy_search","`","]","if","`","num_beams=1","`","and","`","do_sample=False","`",".","-","*","multinomial","sampling","*","by","calling","[","`","~generation_flax_utils.FlaxGenerationMixin._sample","`","]","if","`","num_beams=1","`","and","`","do_sample=True","`",".","-","*","beam-search","decoding","*","by","calling","[","`","~generation_utils.FlaxGenerationMixin._beam_search","`","]","if","`","num_beams",">","1","`","and","`","do_sample=False","`","."]
docstr: Validates model kwargs for generation. Generate argument typos will also be caught here.
docstr_tok: ["Validates","model","kwargs","for","generation",".","Generate","argument","typos","will","also","be","caught","here","."]
code: def _validate_model_kwargs(self, model_kwargs: Dict[str, Any]):
      """Validates model kwargs for generation. Generate argument typos will also be caught here."""
      unused_model_args = []
      model_args = set(
          inspect.signature(
              self.prepare_inputs_for_generation
          ).parameters
      )
      # `kwargs` if often used to handle optional forward pass inputs like `attention_mask`. If
      # `prepare_inputs_for_generation` doesn't accept `kwargs`, then a stricter check can be made ;)
      if "kwargs" in model_args:
          model_args |= set(inspect.signature(self.__call__).parameters)
      for key, value in model_kwargs.items():
          if value is not None and key not in model_args:
              unused_model_args.append(key)
  
      if unused_model_args:
          raise ValueError(
              f"The following `model_kwargs` are not used by the model: {unused_model_args} (note: typos in the"
              " generate arguments will also show up in this list)"
          )
  
imports: import inspect
  import warnings
  from functools import partial
  from typing import Any, Dict, Optional
  import numpy
  import flax
  import jax
  import jax.numpy
  from jax import lax
  from .generation_flax_logits_process import FlaxForcedBOSTokenLogitsProcessor, FlaxForcedEOSTokenLogitsProcessor, FlaxLogitsProcessorList, FlaxMinLengthLogitsProcessor, FlaxTemperatureLogitsWarper, FlaxTopKLogitsWarper, FlaxTopPLogitsWarper
  from .models.auto import FLAX_MODEL_FOR_CAUSAL_LM_MAPPING, FLAX_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, FLAX_MODEL_FOR_VISION_2_SEQ_MAPPING
  from .utils import ModelOutput, logging
label_desc: Use image node_id 6 for calling the FlaxGenerationMixin obj's underlying member method code with example usage: obj._validate_model_kwargs(model_kwargs) without return types