docstr: Args:
      hidden_states (`torch.FloatTensor`): input to the layer of shape `(batch, seq_len, embed_dim)`
      attention_mask (`torch.FloatTensor`): attention mask of size
          `(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
      layer_head_mask (`torch.FloatTensor`): mask for attention heads in a given layer of size
          `(encoder_attention_heads,)`.
      output_attentions (`bool`, *optional*):
          Whether or not to return the attentions tensors of all attention layers. See `attentions` under
          returned tensors for more detail.
docstr_tok: ["Args",":","hidden_states","(","`","torch.FloatTensor","`",")",":","input","to","the","layer","of","shape","`","(","batch",",","seq_len",",","embed_dim",")","`","attention_mask","(","`","torch.FloatTensor","`",")",":","attention","mask","of","size","`","(","batch",",","1",",","tgt_len",",","src_len",")","`","where","padding","elements","are","indicated","by","very","large","negative","values",".","layer_head_mask","(","`","torch.FloatTensor","`",")",":","mask","for","attention","heads","in","a","given","layer","of","size","`","(","encoder_attention_heads",",",")","`",".","output_attentions","(","`","bool","`",",","*","optional","*",")",":","Whether","or","not","to","return","the","attentions","tensors","of","all","attention","layers",".","See","`","attentions","`","under","returned","tensors","for","more","detail","."]
code: def forward(
      self,
      hidden_states: torch.Tensor,
      attention_mask: torch.Tensor,
      layer_head_mask: torch.Tensor,
      output_attentions: bool = False,
  ) -> torch.Tensor:
      """
      Args:
          hidden_states (`torch.FloatTensor`): input to the layer of shape `(batch, seq_len, embed_dim)`
          attention_mask (`torch.FloatTensor`): attention mask of size
              `(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
          layer_head_mask (`torch.FloatTensor`): mask for attention heads in a given layer of size
              `(encoder_attention_heads,)`.
          output_attentions (`bool`, *optional*):
              Whether or not to return the attentions tensors of all attention layers. See `attentions` under
              returned tensors for more detail.
      """
      residual = hidden_states
      hidden_states = self.self_attn_layer_norm(hidden_states)
      hidden_states, attn_weights, _ = self.self_attn(
          hidden_states=hidden_states,
          attention_mask=attention_mask,
          layer_head_mask=layer_head_mask,
          output_attentions=output_attentions,
      )
      hidden_states = nn.functional.dropout(
          hidden_states, p=self.dropout, training=self.training
      )
      hidden_states = residual + hidden_states
  
      residual = hidden_states
      hidden_states = self.final_layer_norm(hidden_states)
      hidden_states = self.activation_fn(self.fc1(hidden_states))
      hidden_states = nn.functional.dropout(
          hidden_states,
          p=self.activation_dropout,
          training=self.training,
      )
      hidden_states = self.fc2(hidden_states)
      hidden_states = nn.functional.dropout(
          hidden_states, p=self.dropout, training=self.training
      )
      hidden_states = residual + hidden_states
  
      if hidden_states.dtype == torch.float16 and (
          torch.isinf(hidden_states).any()
          or torch.isnan(hidden_states).any()
      ):
          clamp_value = torch.finfo(hidden_states.dtype).max - 1000
          hidden_states = torch.clamp(
              hidden_states, min=-clamp_value, max=clamp_value
          )
  
      outputs = (hidden_states,)
  
      if output_attentions:
          outputs += (attn_weights,)
  
      return outputs
  
imports: import math
  from typing import List, Optional, Tuple, Union
  import torch
  from torch import nn
  from torch.nn import CrossEntropyLoss
  from ...activations import ACT2FN
  from ...integrations.deepspeed import is_deepspeed_zero3_enabled
  from ...modeling_attn_mask_utils import _prepare_4d_attention_mask, _prepare_4d_causal_attention_mask
  from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPastAndCrossAttentions, Seq2SeqLMOutput, Seq2SeqModelOutput
  from ...modeling_utils import PreTrainedModel
  from ...utils import add_code_sample_docstrings, add_end_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging, replace_return_docstrings
  from .configuration_m2m_100 import M2M100Config
label_desc: Use image node_id 2 for calling the M2M100EncoderLayer obj's underlying member method code with example usage: obj.forward(hidden_states, attention_mask, layer_head_mask, output_attentions) and returns: outputs