code: def forward(
      self,
      hidden_states: torch.Tensor,
      attention_mask: Optional[torch.FloatTensor] = None,
      head_mask: Optional[torch.FloatTensor] = None,
      output_attentions: bool = False,
  ) -> Union[Tuple[torch.Tensor], Tuple[torch.Tensor, torch.Tensor]]:
      attention_mask = prefix_attention_mask(attention_mask)  # type: ignore
  
      mixed_query_layer = self.query(hidden_states)
      mixed_key_layer = self.key(hidden_states)
      mixed_value_layer = self.value(hidden_states)
  
      query_layer = self.transpose_for_scores(mixed_query_layer)
      key_layer = self.transpose_for_scores(mixed_key_layer)
      value_layer = self.transpose_for_scores(mixed_value_layer)
      (
          query_layer,
          key_layer,
          value_layer,
      ) = match_attn_matrices_for_parallel(
          query_layer, key_layer, value_layer
      )
      (attention_mask,) = adjust_tensors_for_parallel(
          query_layer, attention_mask
      )
  
      key_layer, value_layer, attention_mask = self.prefix_tuning(
          key_layer, value_layer, hidden_states, attention_mask
      )
      (query_layer,) = adjust_tensors_for_parallel(
          key_layer, query_layer
      )
  
      # Take the dot product between "query" and "key" to get the raw attention scores.
      attention_scores = torch.matmul(
          query_layer, key_layer.transpose(-1, -2)
      )
      attention_scores = attention_scores / math.sqrt(
          self.attention_head_size
      )
  
      if attention_mask is not None:
          # Apply the attention mask is (precomputed for all layers in BertModel forward() function)
          attention_scores = attention_scores + attention_mask
  
      if (
          self.position_embedding_type == "relative_key"
          or self.position_embedding_type == "relative_key_query"
      ):
          seq_length = hidden_states.size()[1]
          position_ids_l = torch.arange(
              seq_length, dtype=torch.long, device=hidden_states.device
          ).view(-1, 1)
          position_ids_r = torch.arange(
              seq_length, dtype=torch.long, device=hidden_states.device
          ).view(1, -1)
          distance = position_ids_l - position_ids_r
          positional_embedding = self.distance_embedding(
              distance + self.max_position_embeddings - 1
          )
          positional_embedding = positional_embedding.to(
              dtype=query_layer.dtype
          )  # fp16 compatibility
  
          if self.position_embedding_type == "relative_key":
              relative_position_scores = torch.einsum(
                  "bhld,lrd->bhlr", query_layer, positional_embedding
              )
              attention_scores = (
                  attention_scores + relative_position_scores
              )
          elif self.position_embedding_type == "relative_key_query":
              relative_position_scores_query = torch.einsum(
                  "bhld,lrd->bhlr", query_layer, positional_embedding
              )
              relative_position_scores_key = torch.einsum(
                  "bhrd,lrd->bhlr", key_layer, positional_embedding
              )
              attention_scores = (
                  attention_scores
                  + relative_position_scores_query
                  + relative_position_scores_key
              )
  
      # Normalize the attention scores to probabilities.
      attention_probs = nn.functional.softmax(attention_scores, dim=-1)
  
      # This is actually dropping out entire tokens to attend to, which might
      # seem a bit unusual, but is taken from the original Transformer paper.
      attention_probs = self.attention_dropout(attention_probs)
  
      # Mask heads if we want to
      if head_mask is not None:
          attention_probs = attention_probs * head_mask
  
      context_layer = torch.matmul(attention_probs, value_layer)
      context_layer = context_layer.transpose(2, 1).flatten(2)
  
      projected_context_layer = self.dense(context_layer)
      projected_context_layer_dropout = self.output_dropout(
          projected_context_layer
      )
  
      layernormed_context_layer = self.attention_adapters(
          hidden_states, projected_context_layer_dropout, self.LayerNorm
      )
  
      return (
          (layernormed_context_layer, attention_probs)
          if output_attentions
          else (layernormed_context_layer,)
      )
  
file_path: adapters/src/adapters/models/albert/modeling_albert.py
imports: import math
  from typing import Optional, Tuple, Union
  import torch
  from torch import nn
  from transformers.models.albert.modeling_albert import AlbertAttention, AlbertLayer
  from transformers.pytorch_utils import apply_chunking_to_forward
  from ...composition import adjust_tensors_for_parallel, match_attn_matrices_for_parallel
  from ...utils import prefix_attention_mask
  from .mixin_albert import AlbertAttentionAdaptersMixin, AlbertEncoderLayerAdaptersMixin
label_desc: Use image node_id 1 for calling the AlbertAttentionWithAdapters obj's underlying member method code with example usage: obj.forward(hidden_states, attention_mask, head_mask, output_attentions) and returns: unknown