class_docstr: Adapter Mixin that can augment a ModelPT subclass with Adapter support.
  
  This mixin class should be used only with a top level ModelPT subclass.
  This mixin class adds several utility methods which should be subclassed and overriden to
  propagated to the submodules 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_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.*`.
  
  .. note::
  
      This module **is** responsible for maintaining its config. At the ModelPT level, it will access and
      write Adapter config information to `self.cfg.adapters`.
class_docstr_tok: ["Adapter","Mixin","that","can","augment","a","ModelPT","subclass","with","Adapter","support",".","This","mixin","class","should","be","used","only","with","a","top","level","ModelPT","subclass",".","This","mixin","class","adds","several","utility","methods","which","should","be","subclassed","and","overriden","to","propagated","to","the","submodules","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_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.","*","`",".","..","note",":",":","This","module","*","*","is","*","*","responsible","for","maintaining","its","config",".","At","the","ModelPT","level",",","it","will","access","and","write","Adapter","config","information","to","`","self.cfg.adapters","`","."]
docstr: Updated the internal adapter config, determining if an adapter (or all adapters) are either
  enabled or disabled.
  
  A common user pattern would be to disable all adapters (either after adding them, or restoring a model
  with pre-existing adapters) and then simply enable one of the adapters.
  
  Should be overridden by subclass and super() call must be used - this will setup the config.
  After calling super(), forward this call to modules that implement the mixin.
  
  .. code::
  
      model.set_enabled_adapters(enabled=False)
      model.set_enabled_adapters(name=<some adapter name>, enabled=True)
  
  Args:
      name: Optional str. If a str name is given, the config will be updated to the value of `enabled`.
          If no name is given, then all adapters will be enabled/disabled.
      enabled: Bool, determines if the adapter(s) will be enabled/disabled.
docstr_tok: ["Updated","the","internal","adapter","config",",","determining","if","an","adapter","(","or","all","adapters",")","are","either","enabled","or","disabled",".","A","common","user","pattern","would","be","to","disable","all","adapters","(","either","after","adding","them",",","or","restoring","a","model","with","pre-existing","adapters",")","and","then","simply","enable","one","of","the","adapters",".","Should","be","overridden","by","subclass","and","super","(",")","call","must","be","used","-","this","will","setup","the","config",".","After","calling","super","(",")",",","forward","this","call","to","modules","that","implement","the","mixin",".","..","code",":",":","model.set_enabled_adapters","(","enabled=False",")","model.set_enabled_adapters","(","name=","<","some","adapter","name",">",",","enabled=True",")","Args",":","name",":","Optional","str",".","If","a","str","name","is","given",",","the","config","will","be","updated","to","the","value","of","`","enabled","`",".","If","no","name","is","given",",","then","all","adapters","will","be","enabled\/disabled",".","enabled",":","Bool",",","determines","if","the","adapter","(","s",")","will","be","enabled\/disabled","."]
code: def set_enabled_adapters(
      self, name: Optional[str] = None, enabled: bool = True
  ):
      """
      Updated the internal adapter config, determining if an adapter (or all adapters) are either
      enabled or disabled.
  
      A common user pattern would be to disable all adapters (either after adding them, or restoring a model
      with pre-existing adapters) and then simply enable one of the adapters.
  
      Should be overridden by subclass and super() call must be used - this will setup the config.
      After calling super(), forward this call to modules that implement the mixin.
  
      .. code::
  
          model.set_enabled_adapters(enabled=False)
          model.set_enabled_adapters(name=<some adapter name>, enabled=True)
  
      Args:
          name: Optional str. If a str name is given, the config will be updated to the value of `enabled`.
              If no name is given, then all adapters will be enabled/disabled.
          enabled: Bool, determines if the adapter(s) will be enabled/disabled.
      """
      self.check_valid_model_with_adapter_support_()
  
      # Update the adapter config with information about whether it is enabled/disabled.
      with open_dict(self.cfg.adapters):
          # If no name is provided, update all adapters.
          if name is None:
              for key in self.cfg.adapters.keys():
                  # Skip the global adapter config
                  if key == self.adapter_global_cfg_key:
                      continue
  
                  self.cfg.adapters[key]["enabled"] = enabled
                  logging.info(
                      f"Setting adapter '{key}' status : Enabled = {enabled}"
                  )
  
          else:
              # Resolve the module name and adapter name
              (
                  module_name,
                  adapter_name,
              ) = self.resolve_adapter_module_name_(name)
  
              # Cannot set the state of the global config for adapters
              if adapter_name == self.adapter_global_cfg_key:
                  raise ValueError(
                      f"Cannot set the state of the global config of adapters, "
                      f"given name = `{self.adapter_global_cfg_key}`"
                  )
  
              # Otherwise, update just the specified adapter.
              self.cfg.adapters[adapter_name]["enabled"] = enabled
              logging.info(
                  f"Setting adapter '{name}' status : Enabled = {enabled}"
              )
  
          self.update_adapter_cfg(self.cfg.adapters)
  
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 4 for calling the AdapterModelPTMixin obj's underlying member method code with example usage: obj.set_enabled_adapters(name, enabled) without return types