class_docstr: A class providing methods for saving and loading AdapterFusion modules from the file system.
class_docstr_tok: ["A","class","providing","methods","for","saving","and","loading","AdapterFusion","modules","from","the","file","system","."]
docstr: Extracts the weights of a given AdapterFusion from the model and returns them as a state dict.
  
  Args:
      name (str): The name of the AdapterFusion to be saved.
  
  Returns:
      Tuple[dict, dict]: A tuple consisting of the state dict containing the AdapterFusion weights and the
      AdapterFusion configuration.
code: def save_to_state_dict(self, name: str):
      """
      Extracts the weights of a given AdapterFusion from the model and returns them as a state dict.
  
      Args:
          name (str): The name of the AdapterFusion to be saved.
  
      Returns:
          Tuple[dict, dict]: A tuple consisting of the state dict containing the AdapterFusion weights and the
          AdapterFusion configuration.
      """
      if name not in self.model.adapters_config.fusions:
          raise ValueError(
              f"No AdapterFusion with name '{name}' available."
          )
  
      adapter_fusion_config = self.model.adapters_config.get_fusion(
          name
      )
  
      config_dict = build_full_config(
          adapter_fusion_config,
          self.model.config,
          model_name=self.model.model_name,
          name=name,
          model_class=self.model.__class__.__name__,
      )
  
      # Save adapter weights
      filter_func = self.filter_func(name)
      state_dict = self.weights_helper.state_dict(filter_func)
  
      return state_dict, config_dict
  
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 4 for calling the AdapterFusionLoader obj's underlying member method code with example usage: obj.save_to_state_dict(name) and returns: state_dict,  config_dict