class_docstr: This corresponds to the Block class in the timm implementation.
class_docstr_tok: ["This","corresponds","to","the","Block","class","in","the","timm","implementation","."]
code: def forward(
      self,
      hidden_states: torch.Tensor,
      head_mask: Optional[torch.Tensor] = None,
      output_attentions: bool = False,
  ) -> Union[Tuple[torch.Tensor, torch.Tensor], Tuple[torch.Tensor]]:
      self_attention_outputs = self.attention(
          self.layernorm_before(
              hidden_states
          ),  # in ViT, layernorm is applied before self-attention
          head_mask,
          output_attentions=output_attentions,
      )
      attention_output = self_attention_outputs[0]
      outputs = self_attention_outputs[
          1:
      ]  # add self attentions if we output attention weights
  
      hidden_states = self.attention_adapters.bottleneck_layer_forward(
          attention_output, hidden_states, None
      )
  
      # in ViT, layernorm is also applied after self-attention
      layer_output = self.layernorm_after(hidden_states)
      layer_output = self.intermediate(layer_output)
  
      # second residual connection is done here
      layer_output = self.output(layer_output, hidden_states)
  
      outputs = (layer_output,) + outputs
  
      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 ViTLayerWithAdapters obj's underlying member method code with example usage: obj.forward(hidden_states, head_mask, output_attentions) and returns: outputs