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.
          `(config.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",".","`","(","config.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,
      causal_attention_mask: torch.Tensor,
      output_attentions: Optional[bool] = False,
  ) -> Tuple[torch.FloatTensor]:
      """
      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.
              `(config.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.layer_norm1(hidden_states)
      hidden_states, attn_weights = self.self_attn(
          hidden_states=hidden_states,
          attention_mask=attention_mask,
          causal_attention_mask=causal_attention_mask,
          output_attentions=output_attentions,
      )
      hidden_states = residual + hidden_states
  
      residual = hidden_states
      hidden_states = self.layer_norm2(hidden_states)
      hidden_states = self.mlp(hidden_states)
      hidden_states = residual + hidden_states
  
      outputs = (hidden_states,)
  
      if output_attentions:
          outputs += (attn_weights,)
  
      return outputs
  
imports: from dataclasses import dataclass
  from typing import Optional, Tuple, Union
  import torch
  import torch.utils.checkpoint
  from torch import nn
  from transformers.activations import ACT2FN
  from transformers.modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling
  from transformers.utils import ModelOutput, logging
  from text_generation_server.utils.layers import TensorParallelColumnLinear, TensorParallelRowLinear, TensorParallelEmbedding
label_desc: Use image node_id 2 for calling the IdeficsVisionEncoderLayer obj's underlying member method code with example usage: obj.forward(hidden_states, attention_mask, causal_attention_mask, output_attentions) and returns: outputs