code: def format_parameters(
      parameters: Parameters,
      formatted_search_space: FormattedSearchSpace,
  ) -> FormattedParameters:
      """
      Convert end users' parameter format back to internal format, mainly for resuming experiments.
  
      The result is not accurate for "q*" and for "choice" that have duplicate candidates.
      """
      # I don't like this function. It's better to use checkpoint for resuming.
      ret = {}
      for key, spec in formatted_search_space.items():
          if not spec.is_activated_in(ret):
              continue
          value: Any = parameters
          for name in key:
              if isinstance(name, str):
                  value = value[name]
          if spec.categorical:
              if spec.type == "randint":
                  lower = min(math.ceil(float(x)) for x in spec.values)
                  ret[key] = value - lower
              elif _is_nested_choices(spec.values):
                  names = [nested["_name"] for nested in spec.values]
                  ret[key] = names.index(value["_name"])
              else:
                  ret[key] = spec.values.index(value)
          else:
              if spec.log_distributed:
                  value = math.log(value)
              ret[key] = value
      return ret
  
file_path: nni/nni/common/hpo_utils/formatting.py
imports: from __future__ import annotations
  import math
  from types import SimpleNamespace
  from typing import Any, Dict, NamedTuple, Tuple, cast
  import numpy
  from nni.typehint import Parameters, SearchSpace
label_desc: Use image node_id 3 for calling a global function with example usage: format_parameters(parameters, formatted_search_space) and returns: ret