class_docstr: Testing the best point utilities functionality that is not tested in
  main `AxClient` testing suite (`TestServiceAPI`).
class_docstr_tok: ["Testing","the","best","point","utilities","functionality","that","is","not","tested","in","main","`","AxClient","`","testing","suite","(","`","TestServiceAPI","`",")","."]
code: def test_derel_opt_config_wrapper(
      self, mock_derelativize: MagicMock
  ) -> None:
      # No change to optimization config without relative constraints/thresholds.
      exp = get_experiment_with_observations(
          observations=[
              [-1, 1, 1],
              [1, 2, 1],
              [3, 3, -1],
              [2, 4, 1],
              [2, 0, 1],
          ],
          constrained=True,
      )
      input_optimization_config = not_none(exp.optimization_config)
      optimization_config = _derel_opt_config_wrapper(
          optimization_config=input_optimization_config
      )
      self.assertEqual(input_optimization_config, optimization_config)
  
      # Add relative constraints.
      for constraint in input_optimization_config.all_constraints:
          constraint.relative = True
  
      # Check errors.
      with self.assertRaisesRegex(
          ValueError,
          "Must specify ModelBridge or Experiment when calling "
          "`_derel_opt_config_wrapper`.",
      ):
          _derel_opt_config_wrapper(
              optimization_config=input_optimization_config
          )
      with self.assertRaisesRegex(
          ValueError,
          "`modelbridge` must have status quo if specified. If `modelbridge` is "
          "unspecified, `experiment` must have a status quo.",
      ):
          _derel_opt_config_wrapper(
              optimization_config=input_optimization_config,
              experiment=exp,
          )
  
      # Set status quo.
      exp.status_quo = exp.trials[0].arms[0]
  
      # ModelBridges will have specific addresses and so must be self-same to
      # pass equality checks.
      test_modelbridge_1 = get_tensor_converter_model(
          experiment=not_none(exp),
          data=not_none(exp).lookup_data(),
      )
      test_observations_1 = test_modelbridge_1.get_training_data()
      returned_value = _derel_opt_config_wrapper(
          optimization_config=input_optimization_config,
          modelbridge=test_modelbridge_1,
          observations=test_observations_1,
      )
      mock_derelativize.assert_called_with(
          optimization_config=input_optimization_config,
          modelbridge=test_modelbridge_1,
          observations=test_observations_1,
      )
      with patch(
          f"{best_point_module}.get_tensor_converter_model",
          return_value=test_modelbridge_1,
      ), patch(
          f"{best_point_module}.ModelBridge.get_training_data",
          return_value=test_observations_1,
      ):
          returned_value = _derel_opt_config_wrapper(
              optimization_config=input_optimization_config,
              experiment=exp,
          )
      self.assertEqual(returned_value, DUMMY_OPTIMIZATION_CONFIG)
      mock_derelativize.assert_called_with(
          optimization_config=input_optimization_config,
          modelbridge=test_modelbridge_1,
          observations=test_observations_1,
      )
  
      # Observations and ModelBridge are not constructed from other inputs when
      # provided.
      test_modelbridge_2 = get_tensor_converter_model(
          experiment=not_none(exp),
          data=not_none(exp).lookup_data(),
      )
      test_observations_2 = test_modelbridge_2.get_training_data()
      with self.assertLogs(
          logger=best_point_logger, level="WARN"
      ) as lg, patch(
          f"{best_point_module}.get_tensor_converter_model",
          return_value=test_modelbridge_2,
      ), patch(
          f"{best_point_module}.ModelBridge.get_training_data",
          return_value=test_observations_2,
      ):
          returned_value = _derel_opt_config_wrapper(
              optimization_config=input_optimization_config,
              experiment=exp,
              modelbridge=test_modelbridge_1,
              observations=test_observations_1,
          )
          self.assertTrue(
              any(
                  "ModelBridge and Experiment provided to "
                  "`_derel_opt_config_wrapper`. Ignoring the latter."
                  in warning
                  for warning in lg.output
              ),
              msg=lg.output,
          )
      self.assertEqual(returned_value, DUMMY_OPTIMIZATION_CONFIG)
      mock_derelativize.assert_called_with(
          optimization_config=input_optimization_config,
          modelbridge=test_modelbridge_1,
          observations=test_observations_1,
      )
  
imports: import random
  from typing import List
  from unittest.mock import MagicMock, patch
  import pandas
  import torch
  from ax.core.arm import Arm
  from ax.core.batch_trial import BatchTrial
  from ax.core.data import Data
  from ax.core.generator_run import GeneratorRun
  from ax.core.objective import ScalarizedObjective
  from ax.core.optimization_config import OptimizationConfig
  from ax.core.outcome_constraint import OutcomeConstraint
  from ax.core.types import ComparisonOp
  from ax.exceptions.core import UserInputError
  from ax.modelbridge.cross_validation import AssessModelFitResult
  from ax.modelbridge.registry import Models
  from ax.modelbridge.torch import TorchModelBridge
  from ax.plot.pareto_utils import get_tensor_converter_model
  from ax.service.utils.best_point import _derel_opt_config_wrapper, _is_row_feasible, extract_Y_from_data, get_best_parameters, get_best_raw_objective_point, logger
  from ax.utils.common.testutils import TestCase
  from ax.utils.common.typeutils import not_none
  from ax.utils.testing.core_stubs import get_branin_experiment, get_branin_metric, get_experiment_with_observations, get_sobol
  from ax.utils.testing.mock import fast_botorch_optimize
label_desc: Use image node_id 7 for calling the TestBestPointUtils obj's underlying member method code with example usage: obj.test_derel_opt_config_wrapper(mock_derelativize) without return types