docstr: Forward pass through the adapter layer.
  NOTE: This method should only be called if the calling module directly inherits from BottleneckLayer.
  Otherwise, call the regular forward() method.
  
  Args:
      hidden_states (torch.Tensor): Input hidden states to the adapter layer.
      residual_input (torch.Tensor): Residual input to the adapter layer.
      layer_norm (torch.nn.Module): Transformer layer normalization module to be used by the adapter layer.
  
  Returns:
      torch.Tensor: Output hidden states of the adapter layer.
docstr_tok: ["Forward","pass","through","the","adapter","layer",".","NOTE",":","This","method","should","only","be","called","if","the","calling","module","directly","inherits","from","BottleneckLayer",".","Otherwise",",","call","the","regular","forward","(",")","method",".","Args",":","hidden_states","(","torch.Tensor",")",":","Input","hidden","states","to","the","adapter","layer",".","residual_input","(","torch.Tensor",")",":","Residual","input","to","the","adapter","layer",".","layer_norm","(","torch.nn.Module",")",":","Transformer","layer","normalization","module","to","be","used","by","the","adapter","layer",".","Returns",":","torch.Tensor",":","Output","hidden","states","of","the","adapter","layer","."]
code: def bottleneck_layer_forward(
      self, hidden_states, residual_input, layer_norm
  ):
      """Forward pass through the adapter layer.
      NOTE: This method should only be called if the calling module directly inherits from BottleneckLayer.
      Otherwise, call the regular forward() method.
  
      Args:
          hidden_states (torch.Tensor): Input hidden states to the adapter layer.
          residual_input (torch.Tensor): Residual input to the adapter layer.
          layer_norm (torch.nn.Module): Transformer layer normalization module to be used by the adapter layer.
  
      Returns:
          torch.Tensor: Output hidden states of the adapter layer.
      """
      # Batch sizes might be different due to prefix tuning w. Parallel block
      (residual_input,) = adjust_tensors_for_parallel(
          hidden_states, residual_input
      )
      # Replicate in both directions as residual might be larger (e.g. GPT-J)
      (hidden_states,) = adjust_tensors_for_parallel(
          residual_input, hidden_states
      )
      adapter_setup = self.get_active_setup()
      if adapter_setup is not None:
          input_hidden_states = hidden_states
  
          state = BottleneckState(
              hidden_states, residual_input, residual_input, layer_norm
          )
          state = self.compose(adapter_setup, state)
          hidden_states, residual_input, _, _, _ = state
  
          last_adapter = self.adapters[adapter_setup.last()]
          hidden_states = last_adapter.post_forward(
              hidden_states,
              input_hidden_states,
              residual_input,
              layer_norm,
          )
  
      elif layer_norm:
          hidden_states = layer_norm(hidden_states + residual_input)
      else:
          hidden_states = hidden_states + residual_input
  
      return hidden_states
  
imports: from typing import Dict, List, Mapping, NamedTuple, Optional, Union
  import torch
  from torch import nn
  from ..composition import AdapterCompositionBlock, Average, BatchSplit, Fuse, Parallel, Split, Stack, adjust_tensors_for_parallel
  from ..configuration import BnConfig
  from ..context import ForwardContext
  from .adapter_layer_base import ComposableAdapterLayerBase
  from .modeling import Adapter, BertFusion, ParallelAdapter
label_desc: Use image node_id 19 for calling the BottleneckLayer obj's underlying member method code with example usage: obj.bottleneck_layer_forward(hidden_states, residual_input, layer_norm) and returns: hidden_states