code: def test_relativize_transform_observations(self) -> None:
      def _check_transform_observations(
          tf: Transform,
          observations: List[Observation],
          expected_mean_and_covar: List[Tuple[np.ndarray, np.ndarray]],
      ) -> None:
          results = tf.transform_observations(observations)
          for i, tsfm_obs in enumerate(results):
              expected_mean, expected_covar = expected_mean_and_covar[i]
              self.assertEqual(tsfm_obs.data.metric_names, metric_names)
              # status quo means must always be zero
              self.assertTrue(
                  np.allclose(tsfm_obs.data.means, expected_mean),
                  tsfm_obs.data.means,
              )
              # status quo covariances must always be zero
              self.assertTrue(
                  np.allclose(tsfm_obs.data.covariance, expected_covar),
                  tsfm_obs.data.covariance,
              )
          # Check untransform
          untsfm_results = tf.untransform_observations(results)
          for i, untsfm_obs in enumerate(untsfm_results):
              obs = observations[i]
              self.assertTrue(
                  np.allclose(untsfm_obs.data.means, obs.data.means)
              )
              self.assertTrue(
                  np.allclose(
                      untsfm_obs.data.covariance, obs.data.covariance
                  )
              )
  
      metric_names = ["foobar", "foobaz"]
      arm_names = ["status_quo", "0_0"]
      obs_data = [
          ObservationData(
              metric_names=metric_names,
              means=np.array([2.0, 5.0]),
              covariance=np.array([[0.1, 0.0], [0.0, 0.2]]),
          ),
          ObservationData(
              metric_names=metric_names,
              means=np.array([1.0, 10.0]),
              covariance=np.array([[0.3, 0.0], [0.0, 0.4]]),
          ),
      ]
      obs_features = [
          ObservationFeatures(parameters={"x": 1}, trial_index=0),
          ObservationFeatures(parameters={"x": 2}, trial_index=0),
      ]
  
      observations = recombine_observations(
          obs_features, obs_data, arm_names
      )
      modelbridge = Mock(
          status_quo=Mock(
              data=obs_data[0],
              features=obs_features[0],
              arm_name=arm_names[0],
          ),
          status_quo_data_by_trial={0: obs_data[0]},
      )
  
      for relativize_cls, expected_mean_and_covar in [
          (
              Relativize,
              [
                  (
                      np.array([0.0, 0.0]),
                      np.array([[0.0, 0.0], [0.0, 0.0]]),
                  ),
                  (
                      np.array([-51.25, 98.4]),
                      np.array([[812.5, 0.0], [0.0, 480.0]]),
                  ),
              ],
          ),
          (
              RelativizeWithConstantControl,
              [
                  (
                      np.array([0.0, 0.0]),
                      np.array([[0.0, 0.0], [0.0, 0.0]]),
                  ),
                  (
                      np.array([-50.0, 100.0]),
                      np.array([[750.0, 0.0], [0.0, 160.0]]),
                  ),
              ],
          ),
      ]:
          tf = relativize_cls(
              search_space=None,
              observations=observations,
              modelbridge=modelbridge,
          )
          # check transform and untransform on observations
          _check_transform_observations(
              tf=tf,
              observations=observations,
              expected_mean_and_covar=expected_mean_and_covar,
          )
          # transform should still work when trial_index is None and
          # there is only one sq in modelbridge
          for obs in observations:
              obs.features.trial_index = None
          _check_transform_observations(
              tf=tf,
              observations=observations,
              expected_mean_and_covar=expected_mean_and_covar,
          )
  
      # Check instantiation and subclassing of BaseRelativize
      class BadRelativize(BaseRelativize):
          pass
  
      for abstract_cls in [BaseRelativize, BadRelativize]:
          with self.assertRaisesRegex(
              TypeError, "Can't instantiate abstract class"
          ):
              abstract_cls(
                  search_space=None,
                  observations=observations,
                  modelbridge=modelbridge,
              )
  
imports: from copy import deepcopy
  from typing import List, Tuple
  from unittest.mock import Mock, patch, PropertyMock
  import numpy
  from ax.core import BatchTrial
  from ax.core.observation import Observation, ObservationData, ObservationFeatures, observations_from_data, recombine_observations
  from ax.core.outcome_constraint import OutcomeConstraint
  from ax.core.types import ComparisonOp
  from ax.metrics.branin import BraninMetric
  from ax.modelbridge import ModelBridge
  from ax.modelbridge.registry import Models
  from ax.modelbridge.transforms.base import Transform
  from ax.modelbridge.transforms.relativize import BaseRelativize, Relativize, RelativizeWithConstantControl
  from ax.models.base import Model
  from ax.utils.common.testutils import TestCase
  from ax.utils.common.typeutils import checked_cast, not_none
  from ax.utils.stats.statstools import relativize_data
  from ax.utils.testing.core_stubs import get_branin_data_batch, get_branin_experiment, get_branin_multi_objective_optimization_config, get_branin_optimization_config, get_branin_with_multi_task, get_search_space
  from hypothesis import assume, given, settings, strategies
label_desc: Use image node_id 3 for calling the RelativizeDataTest obj's underlying member method code with example usage: obj.test_relativize_transform_observations() without return types