class_docstr: Generic Adapter Mixin that can augment any torch.nn.Module with Adapter module support.
  
  This mixin class adds a hierarchical way to add any type of Adapter modules to a pre-existing module.
  Since Models are inherently also nn.Module, this mixin can be attached to any Model or Module.
  This mixin class adds several utility methods which are utilized or overridden as necessary.
  
  An Adapter module is any Pytorch nn.Module that possess a few properties :
  
      -   It's input and output dimension are the same, while the hidden dimension need not be the same.
      -   The final layer of the Adapter module is zero-initialized, so that the residual connection to the adapter
              yields the original output.
  
  This mixin adds the following instance variables to the class this inherits it:
  
      -   `adapter_layer`: A torch.nn.ModuleDict(), whose keys are the names of the adapter (globally unique),
              and values are the Adapter nn.Module().
      -   `adapter_cfg`: A OmegaConf DictConfig object that holds the config of the adapters that are initialized.
      -   `adapter_name`: A str resolved name which is unique key globally, but more than one modules may share
              this name.
      -   `adapter_global_cfg_key`: A str representing a key in the model config that can be provided by the user.
              The value resolves to `global_cfg`, and can be overridden via `model.cfg.adapters.global_cfg.*`.
      -   `adapter_metadata_cfg_key`: A str representing a key in the model config that is used to preserve the
              metadata of the adapter config.
  
  .. note::
  
      This module is **not** responsible for maintaining its config. Subclasses must ensure config is updated
      or preserved as needed. It is the responsibility of the subclasses to propagate the most up to date config to
      lower layers.
class_docstr_tok: ["Generic","Adapter","Mixin","that","can","augment","any","torch.nn.Module","with","Adapter","module","support",".","This","mixin","class","adds","a","hierarchical","way","to","add","any","type","of","Adapter","modules","to","a","pre-existing","module",".","Since","Models","are","inherently","also","nn.Module",",","this","mixin","can","be","attached","to","any","Model","or","Module",".","This","mixin","class","adds","several","utility","methods","which","are","utilized","or","overridden","as","necessary",".","An","Adapter","module","is","any","Pytorch","nn.Module","that","possess","a","few","properties",":","-","It","'s","input","and","output","dimension","are","the","same",",","while","the","hidden","dimension","need","not","be","the","same",".","-","The","final","layer","of","the","Adapter","module","is","zero-initialized",",","so","that","the","residual","connection","to","the","adapter","yields","the","original","output",".","This","mixin","adds","the","following","instance","variables","to","the","class","this","inherits","it",":","-","`","adapter_layer","`",":","A","torch.nn.ModuleDict","(",")",",","whose","keys","are","the","names","of","the","adapter","(","globally","unique",")",",","and","values","are","the","Adapter","nn.Module","(",")",".","-","`","adapter_cfg","`",":","A","OmegaConf","DictConfig","object","that","holds","the","config","of","the","adapters","that","are","initialized",".","-","`","adapter_name","`",":","A","str","resolved","name","which","is","unique","key","globally",",","but","more","than","one","modules","may","share","this","name",".","-","`","adapter_global_cfg_key","`",":","A","str","representing","a","key","in","the","model","config","that","can","be","provided","by","the","user",".","The","value","resolves","to","`","global_cfg","`",",","and","can","be","overridden","via","`","model.cfg.adapters.global_cfg.","*","`",".","-","`","adapter_metadata_cfg_key","`",":","A","str","representing","a","key","in","the","model","config","that","is","used","to","preserve","the","metadata","of","the","adapter","config",".","..","note",":",":","This","module","is","*","*","not","*","*","responsible","for","maintaining","its","config",".","Subclasses","must","ensure","config","is","updated","or","preserved","as","needed",".","It","is","the","responsibility","of","the","subclasses","to","propagate","the","most","up","to","date","config","to","lower","layers","."]
docstr: Forward's all active adapters one by one with the provided input, and chaining the outputs of each
  adapter layer to the next.
  
  Utilizes the implicit merge strategy of each adapter when computing the adapter's output, and
  how that output will be merged back with the original input.
  
  Args:
      input: 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.
  
  Returns:
      The result tensor, after all active adapters have finished their forward passes.
docstr_tok: ["Forward","'s","all","active","adapters","one","by","one","with","the","provided","input",",","and","chaining","the","outputs","of","each","adapter","layer","to","the","next",".","Utilizes","the","implicit","merge","strategy","of","each","adapter","when","computing","the","adapter","'s","output",",","and","how","that","output","will","be","merged","back","with","the","original","input",".","Args",":","input",":","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",".","Returns",":","The","result","tensor",",","after","all","active","adapters","have","finished","their","forward","passes","."]
code: def forward_enabled_adapters(self, input: "torch.Tensor"):
      """
      Forward's all active adapters one by one with the provided input, and chaining the outputs of each
      adapter layer to the next.
  
      Utilizes the implicit merge strategy of each adapter when computing the adapter's output, and
      how that output will be merged back with the original input.
  
      Args:
          input: 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.
  
      Returns:
          The result tensor, after all active adapters have finished their forward passes.
      """
      enabled_adapters = self.get_enabled_adapters()
      for adapter_name in enabled_adapters:
          adapter_module = self.adapter_layer[adapter_name]
  
          if hasattr(adapter_module, "adapter_strategy"):
              strategy = (
                  adapter_module.adapter_strategy
              )  # type: 'nemo.core.classes.mixins.adapter_mixin_strategies.AbstractAdapterStrategy'
          else:
              raise AttributeError(
                  f"Adapter module `{adapter_name}` does not set the value `adapter_strategy` ! "
                  f"Please set the value of the adapter's strategy with the class "
                  f"{adapter_module.__class__.__module}.{adapter_module.__class__.__name__}."
              )
  
          # Call a single adapter's forward, and accept its output as the new input for the next adapter.
          input = self.forward_single_enabled_adapter_(
              input,
              adapter_module,
              adapter_name=adapter_name,
              adapter_strategy=strategy,
          )
  
      return input
  
imports: import inspect
  from abc import ABC
  from dataclasses import dataclass, is_dataclass
  from typing import List, Optional, Set, Tuple, Union
  import torch
  import torch.nn
  from hydra.utils import instantiate
  from omegaconf import DictConfig, OmegaConf, open_dict
  from nemo.utils import logging, model_utils
label_desc: Use image node_id 9 for calling the AdapterModuleMixin obj's underlying member method code with example usage: obj.forward_enabled_adapters(input) and returns: input