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: The module with this mixin can define a list of adapter names that it will accept.
  This method should be called in the modules init method and set the adapter names the module will expect to be added.
  
  Args:
      adapter_types: A list of str paths that correspond to classes. The class paths will be instantiated to
          ensure that the class path is correct.
docstr_tok: ["The","module","with","this","mixin","can","define","a","list","of","adapter","names","that","it","will","accept",".","This","method","should","be","called","in","the","modules","init","method","and","set","the","adapter","names","the","module","will","expect","to","be","added",".","Args",":","adapter_types",":","A","list","of","str","paths","that","correspond","to","classes",".","The","class","paths","will","be","instantiated","to","ensure","that","the","class","path","is","correct","."]
code: def set_accepted_adapter_types(
      self, adapter_types: List[Union[type, str]]
  ) -> None:
      """
      The module with this mixin can define a list of adapter names that it will accept.
      This method should be called in the modules init method and set the adapter names the module will expect to be added.
  
      Args:
          adapter_types: A list of str paths that correspond to classes. The class paths will be instantiated to
              ensure that the class path is correct.
      """
      # Let user update and set accepted adapter types.
      types = []
      for s in adapter_types:
          if inspect.isclass(s):
              if not issubclass(s, nn.Module):
                  raise ValueError(
                      f"Attempted to add class ({s}) but is not a subclass of torch.nn.Module"
                  )
  
              types.append(s)
          else:
              types.append(model_utils.import_class_by_path(s))
  
      self._accepted_adapter_types = set(types)
  
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 6 for calling the AdapterModuleMixin obj's underlying member method code with example usage: obj.set_accepted_adapter_types(adapter_types) without return types