class_docstr: Implementation of a sequential bottleneck adapter block.
code: def forward(self, x, residual_input, output_gating=False):
      down = self.adapter_down(x)
  
      up = self.adapter_up(down)
      up = up * self.scaling
      output = up
  
      if self.use_gating:
          # x.shape = (batch_size, seq_len, hidden_size)
          gate = torch.sigmoid(self.gate(x))
          gate = torch.mean(gate, dim=1).unsqueeze(-1)
          output = output * gate
  
      # apply residual connection before layer norm if configured in this way
      if self.adapter_residual_before_ln:
          output = output + residual_input
  
      # apply layer norm if available
      if self.add_layer_norm_after:
          output = self.adapter_norm_after(output)
  
      # if residual should be applied after layer norm, apply it here
      if not self.adapter_residual_before_ln:
          output = output + residual_input
  
      if self.use_gating and output_gating:
          return output, down, up, gate
      return output, down, up
  
imports: import math
  import torch
  from torch import nn
  from transformers.activations import get_activation
  from ..configuration import AdapterFusionConfig, BnConfig
  from ..context import ForwardContext
label_desc: Use image node_id 3 for calling the Adapter obj's underlying member method code with example usage: obj.forward(x, residual_input, output_gating) and returns: output,  down,  up, output,  down,  up,  gate