docstr: encoder_hidden_states  (`tf.Tensor` of shape `(batch_size, sequence_length, hidden_size)`, *optional*):
      Sequence of hidden-states at the output of the last layer of the encoder. Used in the cross-attention if
      the model is configured as a decoder.
  encoder_attention_mask (`tf.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
      Mask to avoid performing attention on the padding token indices of the encoder input. This mask is used in
      the cross-attention if the model is configured as a decoder. Mask values selected in `[0, 1]`:
  
      - 1 for tokens that are **not masked**,
      - 0 for tokens that are **masked**.
  
  past_key_values (`Tuple[Tuple[tf.Tensor]]` of length `config.n_layers`)
      contains precomputed key and value hidden states of the attention blocks. Can be used to speed up decoding.
      If `past` are used, the user can optionally input only the last `decoder_input_ids` (those that don't have
      their past key value states given to this model) of shape `(batch_size, 1)` instead of all
      `decoder_input_ids` of shape `(batch_size, sequence_length)`.
  use_cache (`bool`, *optional*, defaults to `True`):
      If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding (see
      `past`). Set to `False` during training, `True` during generation
docstr_tok: ["encoder_hidden_states","(","`","tf.Tensor","`","of","shape","`","(","batch_size",",","sequence_length",",","hidden_size",")","`",",","*","optional","*",")",":","Sequence","of","hidden-states","at","the","output","of","the","last","layer","of","the","encoder",".","Used","in","the","cross-attention","if","the","model","is","configured","as","a","decoder",".","encoder_attention_mask","(","`","tf.Tensor","`","of","shape","`","(","batch_size",",","sequence_length",")","`",",","*","optional","*",")",":","Mask","to","avoid","performing","attention","on","the","padding","token","indices","of","the","encoder","input",".","This","mask","is","used","in","the","cross-attention","if","the","model","is","configured","as","a","decoder",".","Mask","values","selected","in","`","[","0",",","1","]","`",":","-","1","for","tokens","that","are","*","*","not","masked","*","*",",","-","0","for","tokens","that","are","*","*","masked","*","*",".","past_key_values","(","`","Tuple","[","Tuple","[","tf.Tensor","]","]","`","of","length","`","config.n_layers","`",")","contains","precomputed","key","and","value","hidden","states","of","the","attention","blocks",".","Can","be","used","to","speed","up","decoding",".","If","`","past","`","are","used",",","the","user","can","optionally","input","only","the","last","`","decoder_input_ids","`","(","those","that","do","n't","have","their","past","key","value","states","given","to","this","model",")","of","shape","`","(","batch_size",",","1",")","`","instead","of","all","`","decoder_input_ids","`","of","shape","`","(","batch_size",",","sequence_length",")","`",".","use_cache","(","`","bool","`",",","*","optional","*",",","defaults","to","`","True","`",")",":","If","set","to","`","True","`",",","`","past_key_values","`","key","value","states","are","returned","and","can","be","used","to","speed","up","decoding","(","see","`","past","`",")",".","Set","to","`","False","`","during","training",",","`","True","`","during","generation"]
code: def call(
      self,
      input_ids: TFModelInputType | None = None,
      past_key_values: Optional[
          Tuple[Tuple[Union[np.ndarray, tf.Tensor]]]
      ] = None,
      attention_mask: np.ndarray | tf.Tensor | None = None,
      token_type_ids: np.ndarray | tf.Tensor | None = None,
      position_ids: np.ndarray | tf.Tensor | None = None,
      head_mask: np.ndarray | tf.Tensor | None = None,
      inputs_embeds: np.ndarray | tf.Tensor | None = None,
      encoder_hidden_states: np.ndarray | tf.Tensor | None = None,
      encoder_attention_mask: np.ndarray | tf.Tensor | None = None,
      use_cache: Optional[bool] = None,
      output_attentions: Optional[bool] = None,
      output_hidden_states: Optional[bool] = None,
      return_dict: Optional[bool] = None,
      training: Optional[bool] = False,
  ) -> Union[
      TFBaseModelOutputWithPastAndCrossAttentions, Tuple[tf.Tensor]
  ]:
      r"""
      encoder_hidden_states  (`tf.Tensor` of shape `(batch_size, sequence_length, hidden_size)`, *optional*):
          Sequence of hidden-states at the output of the last layer of the encoder. Used in the cross-attention if
          the model is configured as a decoder.
      encoder_attention_mask (`tf.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
          Mask to avoid performing attention on the padding token indices of the encoder input. This mask is used in
          the cross-attention if the model is configured as a decoder. Mask values selected in `[0, 1]`:
  
          - 1 for tokens that are **not masked**,
          - 0 for tokens that are **masked**.
  
      past_key_values (`Tuple[Tuple[tf.Tensor]]` of length `config.n_layers`)
          contains precomputed key and value hidden states of the attention blocks. Can be used to speed up decoding.
          If `past` are used, the user can optionally input only the last `decoder_input_ids` (those that don't have
          their past key value states given to this model) of shape `(batch_size, 1)` instead of all
          `decoder_input_ids` of shape `(batch_size, sequence_length)`.
      use_cache (`bool`, *optional*, defaults to `True`):
          If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding (see
          `past`). Set to `False` during training, `True` during generation
      """
  
      outputs = self.transformer(
          input_ids=input_ids,
          past_key_values=past_key_values,
          attention_mask=attention_mask,
          token_type_ids=token_type_ids,
          position_ids=position_ids,
          head_mask=head_mask,
          inputs_embeds=inputs_embeds,
          encoder_hidden_states=encoder_hidden_states,
          encoder_attention_mask=encoder_attention_mask,
          use_cache=use_cache,
          output_attentions=output_attentions,
          output_hidden_states=output_hidden_states,
          return_dict=return_dict,
          training=training,
      )
  
      return outputs
  
imports: from __future__ import annotations
  from dataclasses import dataclass
  from typing import List, Optional, Tuple, Union
  import numpy
  import tensorflow
  from ...activations_tf import get_tf_activation
  from ...modeling_tf_outputs import TFBaseModelOutputWithPastAndCrossAttentions, TFCausalLMOutputWithCrossAttentions, TFSequenceClassifierOutputWithPast
  from ...modeling_tf_utils import TFCausalLanguageModelingLoss, TFConv1D, TFModelInputType, TFPreTrainedModel, TFSequenceClassificationLoss, TFSequenceSummary, get_initializer, keras_serializable, unpack_inputs
  from ...tf_utils import check_embeddings_within_bounds, shape_list, stable_softmax
  from ...utils import ModelOutput, add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging, replace_return_docstrings
  from .configuration_gpt2 import GPT2Config
label_desc: Use image node_id 2 for calling the TFGPT2Model obj's underlying member method code with example usage: obj.call(input_ids, past_key_values, attention_mask, token_type_ids, position_ids, head_mask, inputs_embeds, encoder_hidden_states, encoder_attention_mask, use_cache, output_attentions, output_hidden_states, return_dict, training) and returns: outputs