code: def test_extract_objective_thresholds(self) -> None:
      outcomes = ["m1", "m2", "m3", "m4"]
      objective = MultiObjective(
          objectives=[
              Objective(metric=Metric(name)) for name in outcomes[:3]
          ]
      )
      objective_thresholds = [
          ObjectiveThreshold(
              metric=Metric(name),
              op=ComparisonOp.LEQ,
              bound=float(i + 2),
              relative=False,
          )
          for i, name in enumerate(outcomes[:3])
      ]
  
      # None of no thresholds
      self.assertIsNone(
          extract_objective_thresholds(
              objective_thresholds=[],
              objective=objective,
              outcomes=outcomes,
          )
      )
  
      # Working case
      obj_t = extract_objective_thresholds(
          objective_thresholds=objective_thresholds,
          objective=objective,
          outcomes=outcomes,
      )
      expected_obj_t_not_nan = np.array([2.0, 3.0, 4.0])
      # pyre-fixme[16]: Optional type has no attribute `__getitem__`.
      self.assertTrue(
          np.array_equal(obj_t[:3], expected_obj_t_not_nan[:3])
      )
      self.assertTrue(np.isnan(obj_t[-1]))
      # pyre-fixme[16]: Optional type has no attribute `shape`.
      self.assertEqual(obj_t.shape[0], 4)
  
      # Returns NaN for objectives without a threshold.
      obj_t = extract_objective_thresholds(
          objective_thresholds=objective_thresholds[:2],
          objective=objective,
          outcomes=outcomes,
      )
      self.assertTrue(
          np.array_equal(obj_t[:2], expected_obj_t_not_nan[:2])
      )
      self.assertTrue(np.isnan(obj_t[-2:]).all())
  
      # Fails if a threshold does not have a corresponding metric.
      objective2 = Objective(Metric("m1"))
      with self.assertRaisesRegex(ValueError, "corresponding metrics"):
          extract_objective_thresholds(
              objective_thresholds=objective_thresholds,
              objective=objective2,
              outcomes=outcomes,
          )
  
      # Works with a single objective, single threshold
      obj_t = extract_objective_thresholds(
          objective_thresholds=objective_thresholds[:1],
          objective=objective2,
          outcomes=outcomes,
      )
      self.assertEqual(obj_t[0], 2.0)
      self.assertTrue(np.all(np.isnan(obj_t[1:])))
      self.assertEqual(obj_t.shape[0], 4)
  
      # Fails if relative
      objective_thresholds[2] = ObjectiveThreshold(
          metric=Metric("m3"), op=ComparisonOp.LEQ, bound=3
      )
      with self.assertRaises(ValueError):
          extract_objective_thresholds(
              objective_thresholds=objective_thresholds,
              objective=objective,
              outcomes=outcomes,
          )
      objective_thresholds[2] = ObjectiveThreshold(
          metric=Metric("m3"),
          op=ComparisonOp.LEQ,
          bound=3,
          relative=True,
      )
      with self.assertRaises(ValueError):
          extract_objective_thresholds(
              objective_thresholds=objective_thresholds,
              objective=objective,
              outcomes=outcomes,
          )
  
imports: from unittest import mock
  from unittest.mock import patch
  import numpy
  from ax.core.arm import Arm
  from ax.core.data import Data
  from ax.core.generator_run import GeneratorRun
  from ax.core.metric import Metric
  from ax.core.objective import MultiObjective, Objective
  from ax.core.observation import ObservationData, ObservationFeatures
  from ax.core.optimization_config import MultiObjectiveOptimizationConfig
  from ax.core.outcome_constraint import ObjectiveThreshold, OutcomeConstraint, ScalarizedOutcomeConstraint
  from ax.core.types import ComparisonOp
  from ax.core.utils import get_pending_observation_features
  from ax.modelbridge.modelbridge_utils import extract_objective_thresholds, extract_outcome_constraints, feasible_hypervolume, observation_data_to_array, pending_observations_as_array_list
  from ax.modelbridge.registry import Models
  from ax.utils.common.constants import Keys
  from ax.utils.common.testutils import TestCase
  from ax.utils.common.typeutils import not_none
  from ax.utils.testing.core_stubs import get_experiment, get_hierarchical_search_space_experiment
  from pyre_extensions import none_throws
label_desc: Use image node_id 3 for calling the TestModelbridgeUtils obj's underlying member method code with example usage: obj.test_extract_objective_thresholds() without return types