docstr: Args:
      hidden_states (`tf.Tensor`): input to the layer of shape *(batch, seq_len, embed_dim)*
      attention_mask (`tf.Tensor`): attention mask of size
          *(batch, 1, tgt_len, src_len)* where padding elements are indicated by very large negative values.
      encoder_hidden_states (`tf.Tensor`):
          cross attention input to the layer of shape *(batch, seq_len, embed_dim)*
      encoder_attention_mask (`tf.Tensor`): encoder attention mask of size
          *(batch, 1, tgt_len, src_len)* where padding elements are indicated by very large negative values.
      layer_head_mask (`tf.Tensor`): mask for attention heads in a given layer of size
          *(decoder_attention_heads,)*
      cross_attn_layer_head_mask (`tf.Tensor`): mask for heads of the cross-attention module.
          *(decoder_attention_heads,)*
      past_key_value (`Tuple(tf.Tensor)`): cached past key and value projection states
code: def call(
      self,
      hidden_states: tf.Tensor,
      attention_mask: tf.Tensor | None = None,
      encoder_hidden_states: tf.Tensor | None = None,
      encoder_attention_mask: tf.Tensor | None = None,
      layer_head_mask: tf.Tensor | None = None,
      cross_attn_layer_head_mask: tf.Tensor | None = None,
      past_key_value: Tuple[tf.Tensor] | None = None,
      training: Optional[bool] = False,
  ) -> Tuple[tf.Tensor, tf.Tensor, Tuple[Tuple[tf.Tensor]]]:
      """
      Args:
          hidden_states (`tf.Tensor`): input to the layer of shape *(batch, seq_len, embed_dim)*
          attention_mask (`tf.Tensor`): attention mask of size
              *(batch, 1, tgt_len, src_len)* where padding elements are indicated by very large negative values.
          encoder_hidden_states (`tf.Tensor`):
              cross attention input to the layer of shape *(batch, seq_len, embed_dim)*
          encoder_attention_mask (`tf.Tensor`): encoder attention mask of size
              *(batch, 1, tgt_len, src_len)* where padding elements are indicated by very large negative values.
          layer_head_mask (`tf.Tensor`): mask for attention heads in a given layer of size
              *(decoder_attention_heads,)*
          cross_attn_layer_head_mask (`tf.Tensor`): mask for heads of the cross-attention module.
              *(decoder_attention_heads,)*
          past_key_value (`Tuple(tf.Tensor)`): cached past key and value projection states
      """
      residual = hidden_states
      hidden_states = self.self_attn_layer_norm(hidden_states)
  
      # Self Attention
      # decoder uni-directional self-attention cached key/values tuple is at positions 1,2
      self_attn_past_key_value = (
          past_key_value[:2] if past_key_value is not None else None
      )
      # add present self-attn cache to positions 1,2 of present_key_value tuple
      (
          hidden_states,
          self_attn_weights,
          present_key_value,
      ) = self.self_attn(
          hidden_states=hidden_states,
          past_key_value=self_attn_past_key_value,
          attention_mask=attention_mask,
          layer_head_mask=layer_head_mask,
      )
      hidden_states = self.dropout(hidden_states, training=training)
      hidden_states = residual + hidden_states
  
      # Cross-Attention Block
      cross_attn_present_key_value = None
      cross_attn_weights = None
      if encoder_hidden_states is not None:
          residual = hidden_states
          hidden_states = self.encoder_attn_layer_norm(hidden_states)
  
          # cross_attn cached key/values tuple is at positions 3,4 of present_key_value tuple
          cross_attn_past_key_value = (
              past_key_value[-2:]
              if past_key_value is not None
              else None
          )
          (
              hidden_states,
              cross_attn_weights,
              cross_attn_present_key_value,
          ) = self.encoder_attn(
              hidden_states=hidden_states,
              key_value_states=encoder_hidden_states,
              attention_mask=encoder_attention_mask,
              layer_head_mask=cross_attn_layer_head_mask,
              past_key_value=cross_attn_past_key_value,
          )
          hidden_states = self.dropout(hidden_states, training=training)
          hidden_states = residual + hidden_states
  
          # add cross-attn to positions 3,4 of present_key_value tuple
          present_key_value = (
              present_key_value + cross_attn_present_key_value
          )
  
      # Fully Connected
      residual = hidden_states
      hidden_states = self.final_layer_norm(hidden_states)
      hidden_states = self.activation_fn(self.fc1(hidden_states))
      hidden_states = self.activation_dropout(
          hidden_states, training=training
      )
      hidden_states = self.fc2(hidden_states)
      hidden_states = self.dropout(hidden_states, training=training)
      hidden_states = residual + hidden_states
  
      return (
          hidden_states,
          self_attn_weights,
          cross_attn_weights,
          present_key_value,
      )
  
imports: from __future__ import annotations
  import math
  import random
  from typing import Any, Optional, Tuple, Union
  import numpy
  import tensorflow
  from ...activations_tf import get_tf_activation
  from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, replace_return_docstrings
  from ...modeling_tf_outputs import TFBaseModelOutputWithPastAndCrossAttentions, TFCausalLMOutputWithCrossAttentions
  from ...modeling_tf_utils import TFCausalLanguageModelingLoss, TFModelInputType, TFPreTrainedModel, TFSharedEmbeddings, get_initializer, keras_serializable, unpack_inputs
  from ...tf_utils import check_embeddings_within_bounds, shape_list, stable_softmax
  from ...utils import logging
  from .configuration_xglm import XGLMConfig
label_desc: Use image node_id 2 for calling the TFXGLMDecoderLayer obj's underlying member method code with example usage: obj.call(hidden_states, attention_mask, encoder_hidden_states, encoder_attention_mask, layer_head_mask, cross_attn_layer_head_mask, past_key_value, training) and returns: hidden_states,  self_attn_weights,  cross_attn_weights,  present_key_value