code: def register_wrappers(
      model: torch.nn.Module,
      config_list: List[Dict[str, Any]],
      mode: Literal["pruning", "quantization", "distillation"],
      existed_wrappers: Dict[str, ModuleWrapper] | None = None,
  ) -> Tuple[
      Dict[str, ModuleWrapper], Dict[str, Dict[str, TargetSpace]]
  ]:
      assert mode in ["pruning", "quantization", "distillation"]
  
      configured_target_spaces = defaultdict(dict)
      existed_wrappers = existed_wrappers if existed_wrappers else {}
      module_wrappers = {k: v for k, v in existed_wrappers.items()}
      identity_module_set = set()
      module_set = set()
      for config in config_list:
          fuse_module_names: List[Tuple[str]]
          (
              modules,
              public_config,
              fuse_module_names,
          ) = select_modules_by_config(model, config)
          if len(fuse_module_names) > 0:
              validate_fused_modules_config(
                  fuse_module_names, model, public_config
              )
          for module_name, module in modules.items():
              module_set.add(module_name)
              fused_modules_pair: Tuple[str] = get_fused_module_list(
                  module_name, mode, fuse_module_names
              )
              if len(fused_modules_pair) > 0:
                  fuse_module_names.remove(fused_modules_pair)
              old_wrapper = module_wrappers.get(module_name, None)
              if len(fused_modules_pair) > 0:  # fusion model
                  identity_module_set.update(fused_modules_pair[1:])
              wrapper, target_spaces = create_module_wrapper(
                  model,
                  module,
                  module_name,
                  mode,
                  public_config,
                  old_wrapper,
                  list(fused_modules_pair),
              )
              module_wrappers[module_name] = wrapper
              configured_target_spaces[module_name].update(
                  target_spaces
              )
          if len(fuse_module_names) > 0:
              raise ValueError(
                  f"{fuse_module_names} can't be fused with {modules.keys()}"
              )
      if module_set.intersection(identity_module_set):
          raise ValueError(
              f"Don't provide quantization settings for identity modules:{module_set.intersection(identity_module_set)}"
          )
      for module_name, module in model.named_modules():
          if module_name in identity_module_set:
              if module_name in module_wrappers and not isinstance(
                  module_wrappers[module_name], IdentityModuleWrapper
              ):
                  warn_msg = f"Wrapper of {module_name} is wrapped, no need to wrap it because of module fusion."
                  raise ValueError(warn_msg)
              module_wrappers[module_name] = IdentityModuleWrapper(
                  module, module_name, None, None
              )
              identity_module_set.remove(module_name)
  
      assert (
          len(identity_module_set) == 0
      ), f"{identity_module_set} do not exist in the model"
  
      return module_wrappers, configured_target_spaces
  
imports: from __future__ import annotations
  from collections import defaultdict
  import logging
  import inspect
  import functools
  from typing import Any, Callable, Dict, List, Tuple, Type, Union, Literal
  import torch
  import torch.nn
  from torch import Tensor
  from .apply_method import pruning_apply_methods, quant_apply_methods
  from .config import select_modules_by_config
  from .setting import INPUT_PREFIX, OUTPUT_PREFIX, canonicalize_settings
  from .target_space import TargetSpace, TargetType, PruningTargetSpace, QuantizationTargetSpace, DistillationTargetSpace
  from .fuse_modules import fuse_modules
  from ..utils import check_bias, update_config, validate_fused_modules_config, get_fused_module_list, get_nested_attr
label_desc: Use image node_id 2 for calling a global function with example usage: register_wrappers(model, config_list, mode, existed_wrappers) and returns: module_wrappers,  configured_target_spaces