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 __init__(
      self,
      search_space: Optional[SearchSpace] = None,
      observations: Optional[List[Observation]] = None,
      modelbridge: Optional[
          "modelbridge_module.base.ModelBridge"
      ] = None,
      config: Optional[TConfig] = None,
  ) -> None:
      assert (
          search_space is not None
      ), "TaskEncode requires search space"
      # Identify parameters that should be transformed
      self.encoded_parameters: Dict[str, Dict[TParamValue, int]] = {}
      self.target_values: Dict[str, int] = {}
      for p in search_space.parameters.values():
          if isinstance(p, ChoiceParameter) and p.is_task:
              if p.is_fidelity:
                  raise ValueError(
                      f"Task parameter {p.name} cannot simultaneously be "
                      "a fidelity parameter."
                  )
              self.encoded_parameters[p.name] = {
                  original_value: transformed_value
                  for transformed_value, original_value in enumerate(
                      p.values
                  )
              }
              self.target_values[p.name] = self.encoded_parameters[
                  p.name
              ][p.target_value]
      self.encoded_parameters_inverse: Dict[
          str, Dict[int, TParamValue]
      ] = {
          p_name: {
              transformed_value: original_value
              for original_value, transformed_value in transforms.items()
          }
          for p_name, transforms in self.encoded_parameters.items()
      }
  
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 1 to create a new TaskEncode object from inherited base classes: OrderedChoiceEncode with example: obj = TaskEncode(search_space, observations, modelbridge, config)