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
  
      if self.megatron_amp_O2:
          state_dict = {
              k.replace("model.", "model.module.", 1): v
              for k, v in state_dict.items()
          }
  
      missing_keys, unexpected_keys = NLPModel.load_state_dict(
          self, state_dict, strict=False
      )
  
      if len(missing_keys) > 0:
          logging.warning(
              "Missing keys were detected during the load. Please double check."
          )
          if len(missing_keys) > 10:
              logging.warning(
                  f"Missing keys: {missing_keys[:10]} and {len(missing_keys) - 10} more."
              )
          else:
              logging.warning(f"Missing keys: {missing_keys}")
      if len(unexpected_keys) > 0:
          logging.critical(
              "Unexpected keys were detected during the load. Please double check."
          )
          logging.critical(f"Unexpected keys: \n{unexpected_keys}")
          raise ValueError(
              "Unexpected keys were detected during the load. Please double check."
          )
  
file_path: NeMo/nemo/collections/nlp/parts/mixins/multimodal_adapter_mixins.py
imports: import os
  import tempfile
  from typing import List, Optional, Union
  import torch
  from omegaconf import DictConfig, OmegaConf, open_dict
  from nemo.collections.nlp.models.nlp_model import NLPModel
  from nemo.collections.nlp.parts.mixins.nlp_adapter_mixins import NLPAdapterModelMixin
  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
  from nemo.utils.model_utils import inject_model_parallel_rank
label_desc: Use image node_id 4 for calling the MultimodalAdapterModelMixin obj's underlying member method code with example usage: obj.load_adapters(filepath, peft_cfgs, map_location) without return types