class_docstr: NLP Adapter Mixin that can augment any transformer-based model with Adapter module support.
  This mixin class should be used only with a top level ModelPT subclass, that includes either a `model` or an `enc_dec_model` submodule.
  This mixin class adds several utility methods to add, load and save adapters.
  
  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 class aims to integrate with PEFT, which is one or more adapters modules.
  The two features of PEFT, layer selection and weight tying, are also supported in this mixin class.
class_docstr_tok: ["NLP","Adapter","Mixin","that","can","augment","any","transformer-based","model","with","Adapter","module","support",".","This","mixin","class","should","be","used","only","with","a","top","level","ModelPT","subclass",",","that","includes","either","a","`","model","`","or","an","`","enc_dec_model","`","submodule",".","This","mixin","class","adds","several","utility","methods","to","add",",","load","and","save","adapters",".","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","class","aims","to","integrate","with","PEFT",",","which","is","one","or","more","adapters","modules",".","The","two","features","of","PEFT",",","layer","selection","and","weight","tying",",","are","also","supported","in","this","mixin","class","."]
docstr: Utility method that restores only the adapter module(s), and not the entire model itself.
  This allows the sharing of adapters which are often just a fraction of the size of the full model,
  enabling easier deliver.
  
  .. note::
  
      During restoration, assumes that the model does not currently already have one or more adapter modules.
  
  Args:
      filepath: Filepath of the .ckpt or .nemo file.
      peft_cfgs: One or more PEFTConfig objects that specify the PEFT method configuration.
          If none, will infer from the .nemo checkpoint
      map_location: Pytorch flag, where to place the adapter(s) state dict(s).
docstr_tok: ["Utility","method","that","restores","only","the","adapter","module","(","s",")",",","and","not","the","entire","model","itself",".","This","allows","the","sharing","of","adapters","which","are","often","just","a","fraction","of","the","size","of","the","full","model",",","enabling","easier","deliver",".","..","note",":",":","During","restoration",",","assumes","that","the","model","does","not","currently","already","have","one","or","more","adapter","modules",".","Args",":","filepath",":","Filepath","of","the",".ckpt","or",".nemo","file",".","peft_cfgs",":","One","or","more","PEFTConfig","objects","that","specify","the","PEFT","method","configuration",".","If","none",",","will","infer","from","the",".nemo","checkpoint","map_location",":","Pytorch","flag",",","where","to","place","the","adapter","(","s",")","state","dict","(","s",")","."]
code: def load_adapters(
      self,
      filepath: str,
      peft_cfgs: Optional[Union[PEFTConfig, List[PEFTConfig]]] = None,
      map_location: str = None,
  ):
      """
      Utility method that restores only the adapter module(s), and not the entire model itself.
      This allows the sharing of adapters which are often just a fraction of the size of the full model,
      enabling easier deliver.
  
      .. note::
  
          During restoration, assumes that the model does not currently already have one or more adapter modules.
  
      Args:
          filepath: Filepath of the .ckpt or .nemo file.
          peft_cfgs: One or more PEFTConfig objects that specify the PEFT method configuration.
              If none, will infer from the .nemo checkpoint
          map_location: Pytorch flag, where to place the adapter(s) state dict(s).
      """
  
      # Determine device
      if map_location is None:
          if torch.cuda.is_available():
              map_location = "cuda"
          else:
              map_location = "cpu"
  
      if filepath.endswith(".nemo"):
          conf, state_dict = self._get_config_and_state_dict_from_nemo(
              filepath, map_location
          )
      elif filepath.endswith(".ckpt"):
          state_dict = torch.load(filepath, map_location)["state_dict"]
      else:
          raise RuntimeError(
              f"{filepath} is not nemo file or ckpt file"
          )
      if not peft_cfgs:
          assert filepath.endswith(
              ".nemo"
          ), "Inferring peft scheme is only supported for .nemo checkpoints. Please supply the `peft_cfgs` argument."
          peft_cfgs = [PEFT_CONFIG_MAP[conf.peft.peft_scheme](conf)]
      self.add_adapter(peft_cfgs)
      assert set(state_dict.keys()) == self.adapter_keys.union(
          self.tunable_base_param_keys
      )
      super().load_state_dict(state_dict, strict=False)
  
imports: import os
  import tempfile
  from typing import List, Optional, Union
  import torch
  from omegaconf import DictConfig, OmegaConf, open_dict
  from nemo.utils.model_utils import inject_model_parallel_rank
  from nemo.collections.nlp.modules.common.megatron.adapters.parallel_adapters import PromptEncoderAdapterConfig
  from nemo.collections.nlp.parts.peft_config import PEFT_CONFIG_MAP, CanonicalAdaptersPEFTConfig, LoraPEFTConfig, PEFTConfig, PtuningPEFTConfig
  from nemo.core.classes.mixins.adapter_mixins import AdapterModuleMixin
  from nemo.core.connectors.save_restore_connector import SaveRestoreConnector
  from nemo.utils import logging, model_utils
label_desc: Use image node_id 9 for calling the NLPAdapterModelMixin obj's underlying member method code with example usage: obj.load_adapters(filepath, peft_cfgs, map_location) without return types