class_docstr: FastPitch Adapter Mixin that can augment any Encoder module with Adapter module support.
  This mixin class should be used only with a top level ModelPT subclass, that includes an `encoder` submodule.
  This mixin class adds several utility methods which are propagated to the `encoder`.
  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: ["FastPitch","Adapter","Mixin","that","can","augment","any","Encoder","module","with","Adapter","module","support",".","This","mixin","class","should","be","used","only","with","a","top","level","ModelPT","subclass",",","that","includes","an","`","encoder","`","submodule",".","This","mixin","class","adds","several","utility","methods","which","are","propagated","to","the","`","encoder","`",".","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.
  .. 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",".","..","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.
      .. 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.
      """
      super().set_enabled_adapters(name=name, enabled=enabled)
  
      # Resolve the module name and adapter name
      if name is not None:
          module_name, _ = self.resolve_adapter_module_name_(name)
      else:
          module_name = None
  
      # Use + as a splitter, in order to share one name across multiple modules
      if module_name is not None and "+" in module_name:
          module_names = module_name.split("+")
      else:
          module_names = [module_name]
  
      for module_name in module_names:
          # Check if encoder adapters should be used
          # Dispatch the call to the encoder.
          if name is None or module_name == "encoder":
              if self.fastpitch.encoder.is_adapter_available():
                  self.fastpitch.encoder.set_enabled_adapters(
                      name=name, enabled=enabled
                  )
  
          # Dispatch the call to the decoder.
          if name is None or module_name in ("", "decoder"):
              if self.fastpitch.decoder.is_adapter_available():
                  self.fastpitch.decoder.set_enabled_adapters(
                      name=name, enabled=enabled
                  )
  
          # Dispatch the call to the duration_predictor.
          if name is None or module_name in ("", "duration_predictor"):
              if (
                  self.fastpitch.duration_predictor.is_adapter_available()
              ):
                  self.fastpitch.duration_predictor.set_enabled_adapters(
                      name=name, enabled=enabled
                  )
  
          # Dispatch the call to the pitch_predictor.
          if name is None or module_name in ("", "pitch_predictor"):
              if self.fastpitch.pitch_predictor.is_adapter_available():
                  self.fastpitch.pitch_predictor.set_enabled_adapters(
                      name=name, enabled=enabled
                  )
  
          # Dispatch the call to the aligner.
          if name is None or module_name in ("", "aligner"):
              if self.fastpitch.aligner.is_adapter_available():
                  self.fastpitch.aligner.set_enabled_adapters(
                      name=name, enabled=enabled
                  )
  
file_path: NeMo/nemo/collections/tts/parts/mixins/fastpitch_adapter_mixins.py
imports: from typing import List, Optional
  from omegaconf import DictConfig, open_dict
  from nemo.core.classes.mixins.adapter_mixins import AdapterModelPTMixin, AdapterModuleMixin
  from nemo.utils import logging, logging_mode
label_desc: Use image node_id 4 for calling the FastPitchAdapterModelMixin obj's underlying member method code with example usage: obj.set_enabled_adapters(name, enabled) without return types