class_docstr: A single block of the Conformer encoder.
  
  Args:
      d_model (int): input dimension of MultiheadAttentionMechanism and PositionwiseFeedForward
      d_ff (int): hidden dimension of PositionwiseFeedForward
      self_attention_model (str): type of the attention layer and positional encoding
          'rel_pos': relative positional embedding and Transformer-XL
          'rel_pos_local_attn': relative positional embedding and Transformer-XL with local attention using
              overlapping chunks. Attention context is determined by att_context_size parameter.
          'abs_pos': absolute positional embedding and Transformer
          Default is rel_pos.
      global_tokens (int): number of tokens to be used for global attention.
          Only relevant if self_attention_model is 'rel_pos_local_attn'.
          Defaults to 0.
      global_tokens_spacing (int): how far apart the global tokens are
          Defaults to 1.
      global_attn_separate (bool): whether the q, k, v layers used for global tokens should be separate.
          Defaults to False.
      n_heads (int): number of heads for multi-head attention
      conv_kernel_size (int): kernel size for depthwise convolution in convolution module
      dropout (float): dropout probabilities for linear layers
      dropout_att (float): dropout probabilities for attention distributions
class_docstr_tok: ["A","single","block","of","the","Conformer","encoder",".","Args",":","d_model","(","int",")",":","input","dimension","of","MultiheadAttentionMechanism","and","PositionwiseFeedForward","d_ff","(","int",")",":","hidden","dimension","of","PositionwiseFeedForward","self_attention_model","(","str",")",":","type","of","the","attention","layer","and","positional","encoding","'rel_pos","'",":","relative","positional","embedding","and","Transformer-XL","'rel_pos_local_attn","'",":","relative","positional","embedding","and","Transformer-XL","with","local","attention","using","overlapping","chunks",".","Attention","context","is","determined","by","att_context_size","parameter",".","'abs_pos","'",":","absolute","positional","embedding","and","Transformer","Default","is","rel_pos",".","global_tokens","(","int",")",":","number","of","tokens","to","be","used","for","global","attention",".","Only","relevant","if","self_attention_model","is","'rel_pos_local_attn","'",".","Defaults","to","0.","global_tokens_spacing","(","int",")",":","how","far","apart","the","global","tokens","are","Defaults","to","1.","global_attn_separate","(","bool",")",":","whether","the","q",",","k",",","v","layers","used","for","global","tokens","should","be","separate",".","Defaults","to","False",".","n_heads","(","int",")",":","number","of","heads","for","multi-head","attention","conv_kernel_size","(","int",")",":","kernel","size","for","depthwise","convolution","in","convolution","module","dropout","(","float",")",":","dropout","probabilities","for","linear","layers","dropout_att","(","float",")",":","dropout","probabilities","for","attention","distributions"]
docstr: Perform the forward step of a single adapter module on some input data.
  
  **Note**: Subclasses can override this method to accommodate more complicate adapter forward steps.
  
  Args:
      input: Dictionary of packed tensors. The dict should contain at least
          `x`: output tensor
          `loc`: Semantic location in module where this adapter was called
          `att_mask`: Optional, Attention mask
          `pos_emb`: Optional, Positional Embedding for Relative Positional Encoding.
          The output tensor of the calling module is the input to the first adapter, whose output
          is then chained to the next adapter until all adapters are consumed.
      adapter_module: The adapter module that is currently required to perform the forward pass.
      adapter_name: The resolved name of the adapter that is undergoing the current forward pass.
      adapter_strategy: A subclass of `AbstractAdapterStrategy`, that determines how the
          output of the adapter should be merged with the input, or if it should be merged at all.
  
  Returns:
      The result tensor, after the current active adapter has finished its forward pass.
docstr_tok: ["Perform","the","forward","step","of","a","single","adapter","module","on","some","input","data",".","*","*","Note","*","*",":","Subclasses","can","override","this","method","to","accommodate","more","complicate","adapter","forward","steps",".","Args",":","input",":","Dictionary","of","packed","tensors",".","The","dict","should","contain","at","least","`","x","`",":","output","tensor","`","loc","`",":","Semantic","location","in","module","where","this","adapter","was","called","`","att_mask","`",":","Optional",",","Attention","mask","`","pos_emb","`",":","Optional",",","Positional","Embedding","for","Relative","Positional","Encoding",".","The","output","tensor","of","the","calling","module","is","the","input","to","the","first","adapter",",","whose","output","is","then","chained","to","the","next","adapter","until","all","adapters","are","consumed",".","adapter_module",":","The","adapter","module","that","is","currently","required","to","perform","the","forward","pass",".","adapter_name",":","The","resolved","name","of","the","adapter","that","is","undergoing","the","current","forward","pass",".","adapter_strategy",":","A","subclass","of","`","AbstractAdapterStrategy","`",",","that","determines","how","the","output","of","the","adapter","should","be","merged","with","the","input",",","or","if","it","should","be","merged","at","all",".","Returns",":","The","result","tensor",",","after","the","current","active","adapter","has","finished","its","forward","pass","."]
code: def forward_single_enabled_adapter_(
      self,
      input: dict,
      adapter_module: torch.nn.Module,
      *,
      adapter_name: str,
      adapter_strategy: "nemo.core.classes.mixins.adapter_mixin_strategies.AbstractAdapterStrategy",
  ):
      """
      Perform the forward step of a single adapter module on some input data.
  
      **Note**: Subclasses can override this method to accommodate more complicate adapter forward steps.
  
      Args:
          input: Dictionary of packed tensors. The dict should contain at least
              `x`: output tensor
              `loc`: Semantic location in module where this adapter was called
              `att_mask`: Optional, Attention mask
              `pos_emb`: Optional, Positional Embedding for Relative Positional Encoding.
              The output tensor of the calling module is the input to the first adapter, whose output
              is then chained to the next adapter until all adapters are consumed.
          adapter_module: The adapter module that is currently required to perform the forward pass.
          adapter_name: The resolved name of the adapter that is undergoing the current forward pass.
          adapter_strategy: A subclass of `AbstractAdapterStrategy`, that determines how the
              output of the adapter should be merged with the input, or if it should be merged at all.
  
      Returns:
          The result tensor, after the current active adapter has finished its forward pass.
      """
      # (input: torch.Tensor, adapter: torch.nn.Module, *, module: 'AdapterModuleMixin')
      x = input["x"]
      loc = input["loc"]
      att_mask = input.get("att_mask", None)
      pos_emb = input.get("pos_emb", None)
  
      if (
          isinstance(adapter_module, adapter_modules.LinearAdapter)
          and loc == "post"
      ):
          output = adapter_strategy(x, adapter_module, module=self)
  
      elif (
          isinstance(adapter_module, MultiHeadAttention)
          and loc == "mha"
      ):
          if self.self_attention_model == "rel_pos":
              x = dict(
                  query=x,
                  key=x,
                  value=x,
                  mask=att_mask,
                  pos_emb=pos_emb,
              )
              output = adapter_strategy(x, adapter_module, module=self)
  
          elif self.self_attention_model == "abs_pos":
              x = dict(query=x, key=x, value=x, mask=att_mask)
              output = adapter_strategy(x, adapter_module, module=self)
  
          else:
              raise ValueError(
                  f"Unsupported value of self_attention_model , provided {self.self_attention_model}!"
              )
  
      else:
          # No adapter compatible, skip
          output = x
  
      input["x"] = output
  
      return input
  
imports: import torch
  from torch import nn
  from torch.nn import LayerNorm
  from nemo.collections.asr.parts.submodules.batchnorm import FusedBatchNorm1d
  from nemo.collections.asr.parts.submodules.causal_convs import CausalConv1D
  from nemo.collections.asr.parts.submodules.multi_head_attention import MultiHeadAttention, RelPositionMultiHeadAttention, RelPositionMultiHeadAttentionLongformer
  from nemo.collections.asr.parts.utils.activations import Swish
  from nemo.collections.common.parts import adapter_modules
  from nemo.collections.common.parts.utils import activation_registry
  from nemo.core.classes.mixins import AccessMixin
  from nemo.core.classes.mixins.adapter_mixins import AdapterModuleMixin
label_desc: Use image node_id 3 for calling the ConformerLayer obj's underlying member method code with example usage: obj.forward_single_enabled_adapter_(input, adapter_module) and returns: input