code: def forward(
      self,
      hidden_states,
      head_mask: Optional[torch.Tensor] = None,
      output_attentions: bool = False,
  ) -> Union[Tuple[torch.Tensor, torch.Tensor], Tuple[torch.Tensor]]:
      mixed_query_layer = self.query(hidden_states)
  
      key_layer = self.transpose_for_scores(self.key(hidden_states))
      value_layer = self.transpose_for_scores(self.value(hidden_states))
      query_layer = self.transpose_for_scores(mixed_query_layer)
  
      (
          query_layer,
          key_layer,
          value_layer,
      ) = match_attn_matrices_for_parallel(
          query_layer, key_layer, value_layer
      )
  
      key_layer, value_layer, _ = self.prefix_tuning(
          key_layer, value_layer, hidden_states
      )
      (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
      )
  
      # 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.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.permute(0, 2, 1, 3).contiguous()
      new_context_layer_shape = context_layer.size()[:-2] + (
          self.all_head_size,
      )
      context_layer = context_layer.view(new_context_layer_shape)
  
      outputs = (
          (context_layer, attention_probs)
          if output_attentions
          else (context_layer,)
      )
  
      return outputs
  
file_path: adapters/src/adapters/models/vit/modeling_vit.py
imports: import math
  from typing import Optional, Tuple, Union
  import torch
  import torch.utils.checkpoint
  from torch import nn
  from adapters.composition import adjust_tensors_for_parallel, match_attn_matrices_for_parallel
  from transformers.models.vit.modeling_vit import ViTLayer, ViTOutput, ViTSelfAttention
  from .mixin_vit import ViTLayerAdaptersMixin, ViTOutputAdaptersMixin, ViTSelfAttentionAdaptersMixin
label_desc: Use image node_id 1 for calling the ViTSelfAttentionWithAdapters obj's underlying member method code with example usage: obj.forward(hidden_states, head_mask, output_attentions) and returns: outputs