code: def test_init_and_properties(self) -> None:
      # Setup some parameters and distributions.
      a_dist = ParameterDistribution(
          parameters=["a"],
          distribution_class="norm",
          distribution_parameters={"loc": 0.0, "scale": 1.0},
      )
      b_dist = ParameterDistribution(
          parameters=["b"],
          distribution_class="binom",
          distribution_parameters={"n": 2, "p": 0.3},
      )
      env1 = RangeParameter(
          name="env1",
          parameter_type=ParameterType.FLOAT,
          lower=0.5,
          upper=5.5,
      )
      env2 = RangeParameter(
          name="env2",
          parameter_type=ParameterType.INT,
          lower=2.0,
          upper=10.0,
      )
      choice_dist = ParameterDistribution(
          parameters=["c"],
          distribution_class="binom",
          distribution_parameters={"n": 2, "p": 0.3},
      )
      env1_dist = ParameterDistribution(
          parameters=["env1"],
          distribution_class="norm",
          distribution_parameters={"loc": 0.0, "scale": 1.0},
      )
      env1_dist_mul = ParameterDistribution(
          parameters=["env1"],
          distribution_class="norm",
          distribution_parameters={"loc": 0.0, "scale": 1.0},
          multiplicative=True,
      )
      env2_dist = ParameterDistribution(
          parameters=["env2"],
          distribution_class="binom",
          distribution_parameters={"n": 2, "p": 0.3},
      )
      mixed_dist = ParameterDistribution(
          parameters=["a", "env1"],
          distribution_class="multivariate_normal",
          distribution_parameters={"mean": [0.0, 0.0]},
      )
      # Error handling.
      with self.assertRaisesRegex(
          UserInputError, "Use SearchSpace instead."
      ):
          RobustSearchSpace(
              parameters=self.parameters,
              parameter_distributions=[],
              num_samples=4,
          )
      with self.assertRaisesRegex(UserInputError, "positive integer"):
          RobustSearchSpace(
              parameters=self.parameters,
              parameter_distributions=[self.ab_dist],
              num_samples=-1,
          )
      with self.assertRaisesRegex(
          UnsupportedError, "all multiplicative"
      ):
          mul_a_dist = a_dist.clone()
          mul_a_dist.multiplicative = True
          RobustSearchSpace(
              parameters=self.parameters,
              parameter_distributions=[mul_a_dist, b_dist],
              num_samples=4,
          )
      with self.assertRaisesRegex(UserInputError, "must be unique"):
          RobustSearchSpace(
              parameters=self.parameters,
              parameter_distributions=[env1_dist],
              num_samples=4,
              environmental_variables=[env1, env1],
          )
      with self.assertRaisesRegex(
          UserInputError, "must have a distribution"
      ):
          RobustSearchSpace(
              parameters=self.parameters,
              parameter_distributions=[env1_dist],
              environmental_variables=[env1, env2],
              num_samples=4,
          )
      with self.assertRaisesRegex(
          UserInputError, "should not be repeated"
      ):
          RobustSearchSpace(
              parameters=self.parameters,
              parameter_distributions=[a_dist],
              num_samples=4,
              environmental_variables=[self.a],
          )
      with self.assertRaisesRegex(
          UserInputError, "Distributions of environmental variables"
      ):
          RobustSearchSpace(
              parameters=self.parameters,
              parameter_distributions=[env1_dist_mul],
              num_samples=4,
              environmental_variables=[env1],
          )
      with self.assertRaisesRegex(
          UserInputError, "multiple parameter distributions"
      ):
          RobustSearchSpace(
              parameters=self.parameters,
              parameter_distributions=[a_dist, a_dist],
              num_samples=4,
          )
      with self.assertRaisesRegex(
          UserInputError, "distribution must be"
      ):
          RobustSearchSpace(
              parameters=self.parameters,
              parameter_distributions=[a_dist, choice_dist],
              num_samples=4,
              # pyre-fixme[6]: For 4th param expected
              #  `Optional[List[ParameterConstraint]]` but got
              #  `List[OrderConstraint]`.
              parameter_constraints=self.constraints,
          )
      with self.assertRaisesRegex(
          UnsupportedError, "Mixing the distribution"
      ):
          RobustSearchSpace(
              parameters=self.parameters,
              parameter_distributions=[mixed_dist],
              num_samples=4,
              environmental_variables=[env1],
              # pyre-fixme[6]: For 5th param expected
              #  `Optional[List[ParameterConstraint]]` but got
              #  `List[OrderConstraint]`.
              parameter_constraints=self.constraints,
          )
      # Test with environmental variables.
      rss = RobustSearchSpace(
          parameters=self.parameters,
          parameter_distributions=[env1_dist, env2_dist],
          num_samples=4,
          environmental_variables=[env1, env2],
          # pyre-fixme[6]: For 5th param expected
          #  `Optional[List[ParameterConstraint]]` but got `List[OrderConstraint]`.
          parameter_constraints=self.constraints,
      )
      self.assertEqual(rss.num_samples, 4)
      self.assertTrue(rss.is_robust)
      self.assertEqual(rss.parameter_constraints, self.constraints)
      self.assertEqual(
          rss.parameters,
          {
              "a": self.a,
              "b": self.b,
              "c": self.c,
              "env1": env1,
              "env2": env2,
          },
      )
      self.assertEqual(
          rss.parameter_distributions, [env1_dist, env2_dist]
      )
      self.assertEqual(
          rss._environmental_distributions, [env1_dist, env2_dist]
      )
      self.assertEqual(rss._perturbation_distributions, [])
      self.assertFalse(rss.multiplicative)
      self.assertEqual(rss._distributional_parameters, {"env1", "env2"})
      self.assertEqual(
          rss._environmental_variables, {"env1": env1, "env2": env2}
      )
      self.assertTrue(
          all(
              rss.is_environmental_variable(p) for p in ["env1", "env2"]
          )
      )
      # Test having both types together.
      mul_a_dist = a_dist.clone()
      mul_a_dist.multiplicative = True
      rss = RobustSearchSpace(
          parameters=self.parameters,
          parameter_distributions=[mul_a_dist, env1_dist],
          num_samples=4,
          environmental_variables=[env1],
      )
      self.assertEqual(
          rss.parameters,
          {
              "a": self.a,
              "b": self.b,
              "c": self.c,
              "env1": env1,
          },
      )
      self.assertEqual(
          rss.parameter_distributions, [mul_a_dist, env1_dist]
      )
      self.assertEqual(rss._environmental_distributions, [env1_dist])
      self.assertEqual(rss._perturbation_distributions, [mul_a_dist])
      self.assertTrue(rss.multiplicative)
      self.assertEqual(rss._distributional_parameters, {"a", "env1"})
      self.assertEqual(rss._environmental_variables, {"env1": env1})
      # Test with input noise.
      rss = RobustSearchSpace(
          parameters=self.parameters,
          parameter_distributions=[a_dist, b_dist],
          num_samples=4,
          # pyre-fixme[6]: For 4th param expected
          #  `Optional[List[ParameterConstraint]]` but got `List[OrderConstraint]`.
          parameter_constraints=self.constraints,
      )
      self.assertTrue(rss.is_robust)
      self.assertEqual(rss.parameter_constraints, self.constraints)
      self.assertEqual(
          rss.parameters,
          {
              "a": self.a,
              "b": self.b,
              "c": self.c,
          },
      )
      self.assertEqual(rss.parameter_distributions, [a_dist, b_dist])
      self.assertEqual(rss._environmental_distributions, [])
      self.assertEqual(
          rss._perturbation_distributions, [a_dist, b_dist]
      )
      self.assertFalse(rss.multiplicative)
      self.assertEqual(rss._distributional_parameters, {"a", "b"})
      self.assertEqual(rss._environmental_variables, {})
      # Tests with a multivariate distribution.
      rss = self.rss1
      self.assertEqual(rss.parameter_constraints, self.constraints)
      self.assertEqual(
          rss.parameters,
          {
              "a": self.a,
              "b": self.b,
              "c": self.c,
          },
      )
      self.assertEqual(rss.parameter_distributions, [self.ab_dist])
      self.assertEqual(rss._environmental_distributions, [])
      self.assertEqual(rss._perturbation_distributions, [self.ab_dist])
      self.assertEqual(rss._distributional_parameters, {"a", "b"})
      self.assertEqual(rss._environmental_variables, {})
      self.assertFalse(
          any(
              rss.is_environmental_variable(p)
              for p in rss.parameters.keys()
          )
      )
  
imports: import dataclasses
  from random import choice
  from typing import cast, List
  from unittest import mock
  import pandas
  from ax.core.arm import Arm
  from ax.core.observation import ObservationFeatures
  from ax.core.parameter import ChoiceParameter, FixedParameter, Parameter, ParameterType, RangeParameter
  from ax.core.parameter_constraint import OrderConstraint, ParameterConstraint, SumConstraint
  from ax.core.parameter_distribution import ParameterDistribution
  from ax.core.search_space import HierarchicalSearchSpace, RobustSearchSpace, RobustSearchSpaceDigest, SearchSpace, SearchSpaceDigest
  from ax.exceptions.core import UnsupportedError, UserInputError
  from ax.utils.common.constants import Keys
  from ax.utils.common.testutils import TestCase
  from ax.utils.testing.core_stubs import get_hierarchical_search_space, get_l2_reg_weight_parameter, get_lr_parameter, get_model_parameter, get_num_boost_rounds_parameter, get_parameter_constraint
label_desc: Use image node_id 2 for calling the TestRobustSearchSpace obj's underlying member method code with example usage: obj.test_init_and_properties() without return types