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 _update_model_kwargs_for_generation(
      outputs: ModelOutput,
      model_kwargs: Dict[str, Any],
      is_encoder_decoder: bool = False,
  ) -> Dict[str, Any]:
      # update past
      if "past_key_values" in outputs:
          model_kwargs["past"] = outputs.past_key_values
      elif "mems" in outputs:
          model_kwargs["past"] = outputs.mems
      elif "past_buckets_states" in outputs:
          model_kwargs["past"] = outputs.past_buckets_states
      else:
          model_kwargs["past"] = None
  
      # update attention mask
      if not is_encoder_decoder:
          if "attention_mask" in model_kwargs:
              attention_mask = model_kwargs["attention_mask"]
              model_kwargs["attention_mask"] = tf.concat(
                  [
                      attention_mask,
                      tf.ones(
                          (shape_list(attention_mask)[0], 1),
                          dtype=tf.int32,
                      ),
                  ],
                  axis=-1,
              )
  
      return 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 17 for calling the TFGenerationMixin obj's underlying member method code with example usage: obj._update_model_kwargs_for_generation(outputs, model_kwargs, is_encoder_decoder) and returns: model_kwargs