code: def transform_choice_values(
      p: ChoiceParameter,
  ) -> Tuple[np.ndarray, ParameterType]:
      """Transforms the choice values and returns the new parameter type.
  
      If the choices were numeric (int or float) and ordered, then they're cast
      to float and rescaled to [0, 1]. Otherwise, they're cast to integers
      `0, 1, ..., n_choices - 1`.
      """
      if p.is_numeric and p.is_ordered:
          # If values are ordered numeric, retain relative distances.
          values = np.array(p.values, dtype=float)
          vmin, vmax = values.min(), values.max()
          if len(values) > 1:
              values = (values - vmin) / (vmax - vmin)
          ptype = ParameterType.FLOAT
      else:
          # If values are unordered or not numeric, use integer encoding.
          # The reason for using integers rather than floats is somewhat arcane - it has
          # to do with slightly different representation of floats in pure python and in
          # PyTorch, which require some careful handling when untransform the choices that
          # a model may generate on the botorch end. Ints do not have this issue, so we
          # are using them here.
          values = np.arange(len(p.values))
          ptype = ParameterType.INT
      return values, ptype
  
file_path: Ax/ax/modelbridge/transforms/choice_encode.py
imports: from typing import Dict, List, Optional, Tuple, TYPE_CHECKING
  import numpy
  from ax.core.observation import Observation, ObservationFeatures
  from ax.core.parameter import ChoiceParameter, Parameter, ParameterType, RangeParameter
  from ax.core.search_space import SearchSpace
  from ax.core.types import TParamValue
  from ax.modelbridge.transforms.base import Transform
  from ax.modelbridge.transforms.utils import ClosestLookupDict, construct_new_search_space
  from ax.models.types import TConfig
label_desc: Use image node_id 1 for calling a global function with example usage: transform_choice_values(p) and returns: values,  ptype