code: def _format_parameter(
      key: ParameterKey, type_: str, values: list[Any]
  ):
      spec = SimpleNamespace(
          name=key[-1],
          type=type_,
          values=values,
          key=key,
          categorical=type_ in ["choice", "randint"],
      )
  
      if spec.categorical:
          if type_ == "choice":
              spec.size = len(values)
          else:
              lower = math.ceil(float(values[0]))
              upper = math.ceil(float(values[1]))
              spec.size = upper - lower
  
      else:
          if type_.startswith("q"):
              spec.q = float(values[2])
          else:
              spec.q = None
          spec.log_distributed = "log" in type_
  
          if "normal" in type_:
              spec.normal_distributed = True
              spec.mu = float(values[0])
              spec.sigma = float(values[1])
  
          else:
              spec.normal_distributed = False
              spec.low = float(values[0])
              spec.high = float(values[1])
              if spec.q is not None:
                  spec.clip = (spec.low, spec.high)
              if spec.log_distributed:
                  # make it align with mu
                  spec.low = math.log(spec.low)
                  spec.high = math.log(spec.high)
  
      return ParameterSpec(**spec.__dict__)
  
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 5 for calling a global function with example usage: _format_parameter(key, type_, values) and returns: ParameterSpec