code: def _transform_search_space(
      search_space: Dict[str, BaseDistribution],
      transform_log: bool,
      transform_step: bool,
  ) -> Tuple[numpy.ndarray, List[numpy.ndarray], numpy.ndarray]:
      assert (
          len(search_space) > 0
      ), "Cannot transform if no distributions are given."
  
      n_bounds = sum(
          len(d.choices)
          if isinstance(d, CategoricalDistribution)
          else 1
          for d in search_space.values()
      )
  
      bounds = numpy.empty((n_bounds, 2), dtype=numpy.float64)
      column_to_encoded_columns: List[numpy.ndarray] = []
      encoded_column_to_column = numpy.empty(
          n_bounds, dtype=numpy.int64
      )
  
      bound_idx = 0
      for distribution in search_space.values():
          d = distribution
          if isinstance(d, CategoricalDistribution):
              n_choices = len(d.choices)
              bounds[bound_idx : bound_idx + n_choices] = (
                  0,
                  1,
              )  # Broadcast across all choices.
              encoded_columns = numpy.arange(
                  bound_idx, bound_idx + n_choices
              )
              encoded_column_to_column[encoded_columns] = len(
                  column_to_encoded_columns
              )
              column_to_encoded_columns.append(encoded_columns)
              bound_idx += n_choices
          elif isinstance(
              d,
              (
                  FloatDistribution,
                  IntDistribution,
              ),
          ):
              if isinstance(d, FloatDistribution):
                  if d.step is not None:
                      half_step = (
                          0.5 * d.step if transform_step else 0.0
                      )
                      bds = (
                          _transform_numerical_param(
                              d.low, d, transform_log
                          )
                          - half_step,
                          _transform_numerical_param(
                              d.high, d, transform_log
                          )
                          + half_step,
                      )
                  else:
                      bds = (
                          _transform_numerical_param(
                              d.low, d, transform_log
                          ),
                          _transform_numerical_param(
                              d.high, d, transform_log
                          ),
                      )
              elif isinstance(d, IntDistribution):
                  half_step = 0.5 * d.step if transform_step else 0.0
                  if d.log:
                      bds = (
                          _transform_numerical_param(
                              d.low - half_step, d, transform_log
                          ),
                          _transform_numerical_param(
                              d.high + half_step, d, transform_log
                          ),
                      )
                  else:
                      bds = (
                          _transform_numerical_param(
                              d.low, d, transform_log
                          )
                          - half_step,
                          _transform_numerical_param(
                              d.high, d, transform_log
                          )
                          + half_step,
                      )
              else:
                  assert (
                      False
                  ), "Should not reach. Unexpected distribution."
  
              bounds[bound_idx] = bds
              encoded_column = numpy.atleast_1d(bound_idx)
              encoded_column_to_column[encoded_column] = len(
                  column_to_encoded_columns
              )
              column_to_encoded_columns.append(encoded_column)
              bound_idx += 1
          else:
              assert False, "Should not reach. Unexpected distribution."
  
      assert bound_idx == n_bounds
  
      return bounds, column_to_encoded_columns, encoded_column_to_column
  
imports: import math
  from typing import Any
  from typing import Dict
  from typing import List
  from typing import Tuple
  from typing import Union
  import numpy
  from optuna.distributions import BaseDistribution
  from optuna.distributions import CategoricalDistribution
  from optuna.distributions import FloatDistribution
  from optuna.distributions import IntDistribution
label_desc: Use image node_id 1 for calling a global function with example usage: _transform_search_space(search_space, transform_log, transform_step) and returns: bounds,  column_to_encoded_columns,  encoded_column_to_column