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","`","]","."]
code: def _expand_inputs_for_generation(
      input_ids: tf.Tensor,
      expand_size: int = 1,
      is_encoder_decoder: bool = False,
      attention_mask: Optional[tf.Tensor] = None,
      encoder_outputs: Optional[ModelOutput] = None,
      **model_kwargs,
  ) -> Tuple[tf.Tensor, Dict[str, Any]]:
      expanded_return_idx = tf.reshape(
          tf.tile(
              tf.reshape(tf.range(tf.shape(input_ids)[0]), (-1, 1)),
              (1, expand_size),
          ),
          (-1,),
      )
      input_ids = tf.gather(input_ids, expanded_return_idx, axis=0)
  
      if "token_type_ids" in model_kwargs:
          token_type_ids = model_kwargs["token_type_ids"]
          model_kwargs["token_type_ids"] = tf.gather(
              token_type_ids, expanded_return_idx, axis=0
          )
  
      if attention_mask is not None:
          model_kwargs["attention_mask"] = tf.gather(
              attention_mask, expanded_return_idx, axis=0
          )
  
      if is_encoder_decoder:
          if encoder_outputs is None:
              raise ValueError(
                  "If `is_encoder_decoder` is True, make sure that `encoder_outputs` is defined."
              )
          encoder_outputs["last_hidden_state"] = tf.gather(
              encoder_outputs.last_hidden_state,
              expanded_return_idx,
              axis=0,
          )
          model_kwargs["encoder_outputs"] = encoder_outputs
      return input_ids, model_kwargs
  
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 15 for calling the TFGenerationMixin obj's underlying member method code with example usage: obj._expand_inputs_for_generation(input_ids, expand_size, is_encoder_decoder, attention_mask, encoder_outputs) and returns: input_ids,  model_kwargs