code: def test_relativize_transform_requires_a_modelbridge_to_have_status_quo_data(
      self,
  ) -> None:
      for relativize_cls in [Relativize, RelativizeWithConstantControl]:
          # modelbridge has no status quo
          sobol = Models.SOBOL(search_space=get_search_space())
          self.assertIsNone(sobol.status_quo)
          with self.assertRaisesRegex(
              ValueError,
              "Cannot relativize data without status quo data",
          ):
              relativize_cls(
                  search_space=None,
                  observations=[],
                  modelbridge=sobol,
              ).transform_observations(
                  observations=[
                      Observation(
                          data=ObservationData(
                              metric_names=["foo"],
                              means=np.array([2]),
                              covariance=np.array([[0.1]]),
                          ),
                          features=ObservationFeatures(
                              parameters={"x": 1}
                          ),
                          arm_name="0_0",
                      )
                  ],
              )
  
          # modelbridge has status quo
          exp = get_branin_experiment(
              with_batch=True,
              with_status_quo=True,
          )
          # making status_quo out of design
          not_none(exp._status_quo)._parameters["x1"] = 10000.0
          for t in exp.trials.values():
              t.mark_running(no_runner_required=True)
              exp.attach_data(
                  get_branin_data_batch(
                      batch=checked_cast(BatchTrial, t)
                  )
              )
              t.mark_completed()
          data = exp.fetch_data()
          modelbridge = ModelBridge(
              search_space=exp.search_space,
              model=Model(),
              transforms=[relativize_cls],
              experiment=exp,
              data=data,
          )
          mean_in_data = data.df.query(
              f"arm_name == '{not_none(exp.status_quo).name}'"
          )["mean"].item()
          # modelbridge.status_quo_data_by_trial is accurate
          self.assertEqual(
              mean_in_data,
              not_none(modelbridge.status_quo_data_by_trial)[0].means[
                  0
              ],
          )
  
          # create a new experiment
          new_exp = get_branin_experiment(
              with_batch=True,
              with_status_quo=True,
          )
          for t in new_exp.trials.values():
              t.mark_running(no_runner_required=True)
              new_exp.attach_data(
                  get_branin_data_batch(
                      batch=checked_cast(BatchTrial, t)
                  )
              )
              t.mark_completed()
          new_data = new_exp.fetch_data()
          new_observations = observations_from_data(
              experiment=new_exp, data=new_data
          )
          # calls modelbridge._set_training_data inside
          modelbridge._set_training_data(
              observations=new_observations,
              search_space=new_exp.search_space,
          )
          # The new data is different from the original data
          self.assertNotEqual(data, new_data)
          self.assertFalse(data.df.equals(new_data.df))
          mean_in_data = new_data.df.query(
              f"arm_name == '{not_none(new_exp.status_quo).name}'"
          )["mean"].item()
          # modelbridge.status_quo_data_by_trial remains accurate
          self.assertEqual(
              mean_in_data,
              not_none(modelbridge.status_quo_data_by_trial)[0].means[
                  0
              ],
          )
  
          # Can still find status_quo_data_by_trial when status_quo name is None
          mb_sq = not_none(modelbridge._status_quo)
          mb_sq.arm_name = None
          self.assertIsNotNone(modelbridge.status_quo_data_by_trial)
  
          # test transform edge cases
          observations = observations_from_data(
              experiment=exp,
              data=data,
          )
          tf = relativize_cls(
              search_space=None,
              observations=observations,
              modelbridge=modelbridge,
          )
          # making observation coming from trial_index not in modelbridge
          observations[0].features.trial_index = 999
          self.assertRaises(
              ValueError, tf.transform_observations, observations
          )
  
          # When observation has missing trial_index and
          # modelbridge.status_quo_data_by_trial has more than one trial,
          # raise exception
          observations[0].features.trial_index = None
          with patch.object(
              type(modelbridge),
              "status_quo_data_by_trial",
              new_callable=PropertyMock,
          ) as mock_sq_dict:
              # Making modelbridge.status_quo_data_by_trial contains 2 trials
              mock_sq_dict.return_value = {0: Mock(), 1: Mock()}
              with self.assertRaisesRegex(
                  ValueError,
                  "Observations contain missing trial index that can't be inferred.",
              ):
                  tf.transform_observations(observations)
  
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 2 for calling the RelativizeDataTest obj's underlying member method code with example usage: obj.test_relativize_transform_requires_a_modelbridge_to_have_status_quo_data() without return types