docstr: Args:
      hidden_states (`torch.FloatTensor`): input to the layer of shape `(seq_len, batch, 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.
      encoder_hidden_states (`torch.FloatTensor`):
          cross attention input to the layer of shape `(seq_len, batch, embed_dim)`
      encoder_attention_mask (`torch.FloatTensor`): encoder 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,)`.
      cross_attn_layer_head_mask (`torch.FloatTensor`): mask for cross-attention heads in a given layer of
          size `(decoder_attention_heads,)`.
      past_key_value (`Tuple(torch.FloatTensor)`): cached past key and value projection states
      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","`","(","seq_len",",","batch",",","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",".","encoder_hidden_states","(","`","torch.FloatTensor","`",")",":","cross","attention","input","to","the","layer","of","shape","`","(","seq_len",",","batch",",","embed_dim",")","`","encoder_attention_mask","(","`","torch.FloatTensor","`",")",":","encoder","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",",",")","`",".","cross_attn_layer_head_mask","(","`","torch.FloatTensor","`",")",":","mask","for","cross-attention","heads","in","a","given","layer","of","size","`","(","decoder_attention_heads",",",")","`",".","past_key_value","(","`","Tuple","(","torch.FloatTensor",")","`",")",":","cached","past","key","and","value","projection","states","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: Optional[torch.Tensor] = None,
      encoder_hidden_states: Optional[torch.Tensor] = None,
      encoder_attention_mask: Optional[torch.Tensor] = None,
      layer_head_mask: Optional[torch.Tensor] = None,
      cross_attn_layer_head_mask: Optional[torch.Tensor] = None,
      past_key_value: Optional[Tuple[torch.Tensor]] = None,
      output_attentions: Optional[bool] = False,
      use_cache: Optional[bool] = True,
  ) -> torch.Tensor:
      """
      Args:
          hidden_states (`torch.FloatTensor`): input to the layer of shape `(seq_len, batch, 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.
          encoder_hidden_states (`torch.FloatTensor`):
              cross attention input to the layer of shape `(seq_len, batch, embed_dim)`
          encoder_attention_mask (`torch.FloatTensor`): encoder 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,)`.
          cross_attn_layer_head_mask (`torch.FloatTensor`): mask for cross-attention heads in a given layer of
              size `(decoder_attention_heads,)`.
          past_key_value (`Tuple(torch.FloatTensor)`): cached past key and value projection states
          output_attentions (`bool`, *optional*):
              Whether or not to return the attentions tensors of all attention layers. See `attentions` under
              returned tensors for more detail.
      """
      adjust_tensors_for_parallel_(
          hidden_states, attention_mask, encoder_attention_mask
      )
  
      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,
          output_attentions=output_attentions,
      )
      hidden_states = nn.functional.dropout(
          hidden_states, p=self.dropout, training=self.training
      )
      hidden_states = self.attention_adapters(
          hidden_states, residual, None
      )
  
      # 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,
              output_attentions=output_attentions,
          )
          hidden_states = nn.functional.dropout(
              hidden_states, p=self.dropout, training=self.training
          )
          hidden_states = self.cross_attention_adapters(
              hidden_states, residual, None
          )
  
          # 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 = 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 = self.output_adapters(
          hidden_states, residual, None
      )
  
      outputs = (hidden_states,)
  
      if output_attentions:
          outputs += (self_attn_weights, cross_attn_weights)
  
      if use_cache:
          outputs += (present_key_value,)
  
      return outputs
  
file_path: adapters/src/adapters/models/mbart/modeling_mbart.py
imports: from typing import Optional, Tuple
  import torch
  import torch.utils.checkpoint
  from torch import nn
  from transformers.models.mbart.modeling_mbart import MBartAttention, MBartDecoderLayer, MBartEncoderLayer
  from ...composition import adjust_tensors_for_parallel, adjust_tensors_for_parallel_, match_attn_matrices_for_parallel
  from ..bart.mixin_bart import BartAttentionAdaptersMixin, BartDecoderLayerAdaptersMixin, BartEncoderLayerAdaptersMixin
label_desc: Use image node_id 1 for calling the MBartDecoderLayerWithAdapters obj's underlying member method code with example usage: obj.forward(hidden_states, attention_mask, encoder_hidden_states, encoder_attention_mask, layer_head_mask, cross_attn_layer_head_mask, past_key_value, output_attentions, use_cache) and returns: outputs