class_docstr: Convert task ChoiceParameters to integer-valued ChoiceParameters.
  
  Parameters will be transformed to an integer ChoiceParameter with
  property `is_task=True`, mapping values from the original choice domain to a
  contiguous range integers `0, 1, ..., n_choices-1`.
  
  In the inverse transform, parameters will be mapped back onto the original domain.
  
  Transform is done in-place.
class_docstr_tok: ["Convert","task","ChoiceParameters","to","integer-valued","ChoiceParameters",".","Parameters","will","be","transformed","to","an","integer","ChoiceParameter","with","property","`","is_task=True","`",",","mapping","values","from","the","original","choice","domain","to","a","contiguous","range","integers","`","0",",","1",",","...",",","n_choices-1","`",".","In","the","inverse","transform",",","parameters","will","be","mapped","back","onto","the","original","domain",".","Transform","is","done","in-place","."]
code: def _transform_search_space(
      self, search_space: SearchSpace
  ) -> SearchSpace:
      transformed_parameters: Dict[str, Parameter] = {}
      for p_name, p in search_space.parameters.items():
          if p_name in self.encoded_parameters and isinstance(
              p, ChoiceParameter
          ):
              if p.is_fidelity:
                  raise ValueError(
                      f"Cannot choice-encode fidelity parameter {p_name}."
                  )
              # Choice(|K|) => Choice(0, K-1, is_task=True)
              transformed_parameters[p_name] = ChoiceParameter(
                  name=p_name,
                  parameter_type=ParameterType.INT,
                  values=list(range(len(p.values))),  # pyre-ignore [6]
                  is_ordered=p.is_ordered,
                  is_task=True,
                  sort_values=True,
                  target_value=self.target_values[p_name],
              )
          else:
              transformed_parameters[p.name] = p
      return construct_new_search_space(
          search_space=search_space,
          parameters=list(transformed_parameters.values()),
          parameter_constraints=[
              pc.clone_with_transformed_parameters(
                  transformed_parameters=transformed_parameters
              )
              for pc in search_space.parameter_constraints
          ],
      )
  
file_path: Ax/ax/modelbridge/transforms/task_encode.py
imports: from typing import Dict, List, Optional, TYPE_CHECKING
  from ax.core.observation import Observation
  from ax.core.parameter import ChoiceParameter, Parameter, ParameterType
  from ax.core.search_space import SearchSpace
  from ax.core.types import TParamValue
  from ax.modelbridge.transforms.choice_encode import OrderedChoiceEncode
  from ax.modelbridge.transforms.utils import construct_new_search_space
  from ax.models.types import TConfig
label_desc: Use image node_id 2 for calling the TaskEncode obj's underlying member method code with example usage: obj._transform_search_space(search_space) and returns: construct_new_search_space