code: def trans_legacy_config_list(
      config_list: List[Dict[str, Any]]
  ) -> List[Dict[str, Any]]:
      """
      Parameters
      ----------
      config_list
          Legacy format config list.
  
      Returns
      -------
      List[Dict[str, Any]]
          New (v2.5) format config list.
      """
      # transfer the old config keys to new config keys
      if not config_list:
          return config_list
  
      if (
          "exclude" not in config_list[0]
          and "sparsity" not in config_list[0]
          and "sparsity_per_layer" not in config_list[0]
          and "total_sparsity" not in config_list[0]
          and "quant_types" not in config_list[0]
      ):
          # all the old keys not in the first config, then we assume this config list is not a legacy config list.
          return config_list
  
      config_list = deepcopy(config_list)
  
      # trans common part
      ex_op_types = set()
      ex_op_names = set()
      ex_op_names_re = set()
      for config in config_list:
          if "op_partial_names" in config:
              config["op_names_re"] = [
                  f".*{p_name}.*"
                  for p_name in config.pop("op_partial_names")
              ]
          if "exclude" in config:
              config.pop("exclude")
              ex_op_types.update(config.get("op_types", set()))
              ex_op_names.update(config.get("op_names", set()))
              ex_op_names_re.update(config.get("op_names_re", set()))
      if ex_op_types or ex_op_names or ex_op_names_re:
          for config in config_list:
              config["exclude_op_types"] = list(ex_op_types)
              config["exclude_op_names"] = list(ex_op_names)
              config["exclude_op_names_re"] = list(ex_op_names_re)
  
      # trans pruning config
      group_id_candidate = 0
      for config in config_list:
          sparse_ratio = None
          group_id = None
          max_sparse_ratio = config.pop("max_sparsity_per_layer", None)
          if "sparsity_per_layer" in config or "sparsity" in config:
              sparse_ratio = config.pop(
                  "sparsity_per_layer", config.pop("sparsity", None)
              )
          if "total_sparsity" in config:
              sparse_ratio = config.pop("total_sparsity")
              group_id = group_id_candidate
              group_id_candidate += 1
          if sparse_ratio is not None:
              config["target_names"] = ["weight", "bias"]
              weight_setting = {
                  "sparse_ratio": sparse_ratio,
                  "granularity": "default",
              }
              if max_sparse_ratio is not None:
                  weight_setting["max_sparse_ratio"] = max_sparse_ratio
              if group_id is not None:
                  weight_setting["group_id"] = group_id
              config["target_settings"] = {"weight": weight_setting}
  
      # trans quantization part
      for config in config_list:
          target_names = []
          target_settings = {}
          if "quant_types" in config:
              quant_types, quant_bits = config.pop(
                  "quant_types"
              ), config.pop("quant_bits")
              if "input" in quant_types:
                  target_names.append(INPUT_PREFIX)
                  quant_bit = (
                      quant_bits
                      if isinstance(quant_bits, int)
                      else quant_bits["input"]
                  )
                  target_settings[INPUT_PREFIX] = {
                      "quant_dtype": f"int{quant_bit}"
                  }
              if "weight" in quant_types:
                  target_names.extend(["weight"])
                  quant_bit = (
                      quant_bits
                      if isinstance(quant_bits, int)
                      else quant_bits["weight"]
                  )
                  target_settings["weight"] = {
                      "quant_dtype": f"int{quant_bit}"
                  }
              if "output" in quant_types:
                  target_names.append(OUTPUT_PREFIX)
                  quant_bit = (
                      quant_bits
                      if isinstance(quant_bits, int)
                      else quant_bits["output"]
                  )
                  target_settings[OUTPUT_PREFIX] = {
                      "quant_dtype": f"int{quant_bit}"
                  }
              config["target_names"] = target_names
              config["target_settings"] = target_settings
      return config_list
  
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 1 for calling a global function with example usage: trans_legacy_config_list(config_list) and returns: config_list, config_list, config_list