code: def construct_new_search_space(
      search_space: SearchSpace,
      parameters: List[Parameter],
      parameter_constraints: Optional[List[ParameterConstraint]] = None,
  ) -> SearchSpace:
      """Construct a search space with the transformed arguments.
  
      If the `search_space` is a `RobustSearchSpace`, this will use its
      environmental variables and distributions, and remove the environmental
      variables from `parameters` before constructing.
  
      Args:
          parameters: List of transformed parameter objects.
          parameter_constraints: List of parameter constraints.
  
      Returns:
          The new search space instance.
      """
      new_kwargs: Dict[str, Any] = {
          "parameters": parameters,
          "parameter_constraints": parameter_constraints,
      }
      if isinstance(search_space, RobustSearchSpace):
          env_vars = list(
              search_space._environmental_variables.values()
          )
          if env_vars:
              # Add environmental variables and remove them from parameters.
              new_kwargs["environmental_variables"] = env_vars
              new_kwargs["parameters"] = [
                  p for p in parameters if p not in env_vars
              ]
          new_kwargs[
              "parameter_distributions"
          ] = search_space.parameter_distributions
          new_kwargs["num_samples"] = search_space.num_samples
      return search_space.__class__(**new_kwargs)
  
imports: from __future__ import annotations
  from collections import defaultdict
  from math import isnan
  from numbers import Number
  from typing import Any, Callable, Dict, List, Optional, Tuple, TYPE_CHECKING, Union
  import numpy
  from ax.core.observation import Observation, ObservationData, ObservationFeatures
  from ax.core.optimization_config import OptimizationConfig
  from ax.core.parameter import Parameter
  from ax.core.parameter_constraint import ParameterConstraint
  from ax.core.search_space import RobustSearchSpace, SearchSpace
  from ax.modelbridge.transforms.derelativize import Derelativize
  from scipy.stats import norm
label_desc: Use image node_id 3 for calling a global function with example usage: construct_new_search_space(search_space, parameters, parameter_constraints) and returns: search_space