class_docstr: A class providing helper methods for saving and loading module weights.
class_docstr_tok: ["A","class","providing","helper","methods","for","saving","and","loading","module","weights","."]
code: def save_weights(self, save_directory, filter_func):
      if not exists(save_directory):
          mkdir(save_directory)
      else:
          assert isdir(
              save_directory
          ), "Saving path should be a directory where the module weights can be saved."
  
      # Get the state of all adapter modules for this task
      state_dict = self.state_dict(filter_func)
      # Save the adapter weights
      output_file = join(save_directory, self.weights_name)
      torch.save(state_dict, output_file)
      logger.info("Module weights saved in {}".format(output_file))
  
imports: import json
  import logging
  from abc import ABC, abstractmethod
  from os import mkdir
  from os.path import exists, isdir, isfile, join
  from typing import Callable, Mapping, Sequence, Tuple
  import torch
  from .configuration import AdapterConfig, build_full_config
  from .head_utils import STATIC_TO_FLEX_HEAD_MAP, get_head_config_and_rename_list
  from .utils import ACTIVATION_RENAME, ADAPTERFUSION_CONFIG_NAME, ADAPTERFUSION_WEIGHTS_NAME, CONFIG_NAME, HEAD_CONFIG_NAME, HEAD_WEIGHTS_NAME, WEIGHTS_NAME, AdapterType, resolve_adapter_path
label_desc: Use image node_id 5 for calling the WeightsLoaderHelper obj's underlying member method code with example usage: obj.save_weights(save_directory, filter_func) without return types