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 _prepare_attention_mask_for_generation(
      self,
      inputs: tf.Tensor,
      pad_token_id: Optional[int],
      eos_token_id: Optional[int],
  ) -> tf.Tensor:
      is_input_ids = len(inputs.shape) == 2 and inputs.dtype in (
          tf.int32,
          tf.int64,
      )
      is_pad_token_in_inputs = (
          pad_token_id is not None
      ) and tf.math.reduce_any(inputs == pad_token_id)
      is_pad_token_not_equal_to_eos_token_id = (
          eos_token_id is None
      ) or (pad_token_id != eos_token_id)
  
      # Check if input is input_ids and padded -> only then is attention_mask defined
      if (
          is_input_ids
          and is_pad_token_in_inputs
          and is_pad_token_not_equal_to_eos_token_id
      ):
          return tf.cast(
              tf.math.not_equal(inputs, pad_token_id), dtype=tf.int32
          )
      else:
          return tf.ones(inputs.shape[:2], dtype=tf.int32)
  
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 11 for calling the TFGenerationMixin obj's underlying member method code with example usage: obj._prepare_attention_mask_for_generation(inputs, pad_token_id, eos_token_id) and returns: tf, tf