code: def extend_target_spaces(
      self,
      sub_config: Dict[str, Any],
      mode: Literal["pruning", "quantization", "distillation"],
  ):
      assert mode in ["pruning", "quantization", "distillation"]
  
      if mode == "pruning":
          target_spaces = self.pruning_target_spaces
          target_space_cls = PruningTargetSpace
      elif mode == "quantization":
          target_spaces = self.quantization_target_spaces
          target_space_cls = QuantizationTargetSpace
      else:
          target_spaces = self.distillation_target_spaces
          target_space_cls = DistillationTargetSpace
  
      settings = canonicalize_settings(self.module, sub_config, mode)
      inter_sec = set(target_spaces.keys()).intersection(
          settings.keys()
      )
      for name in inter_sec:
          # if need to update target space setting, should directly update it, not extend a repeat target.
          warn_msg = f"{name} have already configured, the new config will be ignored."
          _logger.warning(warn_msg)
          settings.pop(name)
      new_target_spaces = self._create_target_spaces(
          settings, target_space_cls
      )
      target_spaces.update(new_target_spaces)  # type: ignore
  
      # return the new registered target spaces
      return new_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 10 for calling the ModuleWrapper obj's underlying member method code with example usage: obj.extend_target_spaces(sub_config, mode) and returns: new_target_spaces