code: def default_config_schema(
      mode: Literal["pruning", "quantization", "distillation"]
  ) -> Schema:
      assert mode in ["pruning", "quantization", "distillation"]
      if mode == "pruning":
          setting_schema = {
              Optional(
                  Or("sparse_ratio", "sparse_threshold", only_one=True)
              ): float,
              Optional("max_sparse_ratio"): lambda x: 0 < x <= 1,
              Optional("min_sparse_ratio"): lambda x: 0 <= x < 1,
              Optional("global_group_id"): Or(int, str),
              Optional("dependency_group_id"): Or(int, str),
              Optional("internal_metric_block"): int,
              Optional("granularity"): Or(
                  "default",
                  "in_channel",
                  "out_channel",
                  "per_channel",
                  list,
              ),
              Optional("apply_method"): Or("bypass", "mul", "add"),
              Optional("align"): {
                  "module_name": Or(str, None),
                  "target_name": str,
                  "dims": list,
              },
          }
      elif mode == "quantization":
          setting_schema = {
              "quant_dtype": Or(str, None),
              Optional("quant_scheme"): Or("affine", "symmetric"),
              Optional("granularity"): Or(
                  "default",
                  "in_channel",
                  "out_channel",
                  "per_channel",
                  list,
              ),
              Optional("apply_method"): Or(
                  "bypass", "clamp_round", "qat_clamp_round"
              ),
              Optional("fuse_names"): [(str,)],
          }
      else:
          setting_schema = {
              Optional("lambda"): Or(int, float),
              Optional("link"): Or(str, [str], (str,)),
              Optional("apply_method"): Or("mse", "kl"),
          }
  
      schema = Schema(
          {
              Or("op_types", "op_names", "op_names_re"): [str],
              Optional("exclude_op_names"): [str],
              Optional("exclude_op_types"): [str],
              Optional("exclude_op_names_re"): [str],
              Optional("target_names"): [str],
              Optional("target_settings"): {str: setting_schema},
              **setting_schema,
          }
      )
  
      return schema
  
file_path: nni/nni/compression/base/config.py
imports: from __future__ import annotations
  from collections import defaultdict
  from copy import deepcopy
  import re
  from typing import Any, Dict, List, Literal, Tuple
  from schema import Schema, Optional, Or
  import torch
  from .setting import INPUT_PREFIX, OUTPUT_PREFIX
label_desc: Use image node_id 3 for calling a global function with example usage: default_config_schema(mode) and returns: schema