code: def test_get_observed_pareto_frontiers(self) -> None:
      experiment = get_branin_experiment_with_multi_objective(
          with_batch=True,
          has_optimization_config=False,
          with_status_quo=True,
      )
  
      # Optimization config is not optional
      with self.assertRaises(ValueError):
          get_observed_pareto_frontiers(
              experiment=experiment, data=Data()
          )
  
      objectives = [
          Objective(
              metric=BraninMetric(
                  name="m1",
                  param_names=["x1", "x2"],
                  lower_is_better=True,
              ),
              minimize=True,
          ),
          Objective(
              metric=NegativeBraninMetric(
                  name="m2",
                  param_names=["x1", "x2"],
                  lower_is_better=True,
              ),
              minimize=True,
          ),
          Objective(
              metric=BraninMetric(
                  name="m3",
                  param_names=["x1", "x2"],
                  lower_is_better=True,
              ),
              minimize=True,
          ),
      ]
      bounds = [0, -100, 1000]
      rels = [True, True, False]
      objective_thresholds = [
          ObjectiveThreshold(
              metric=objective.metric,
              bound=bounds[i],
              relative=rels[i],
              op=ComparisonOp.LEQ,
          )
          for i, objective in enumerate(objectives)
      ]
      objective = MultiObjective(objectives=objectives)
      optimization_config = MultiObjectiveOptimizationConfig(
          objective=objective,
          objective_thresholds=objective_thresholds,
      )
      experiment.optimization_config = optimization_config
      experiment.trials[0].run()
  
      # For the check below, compute which arms are better than SQ
      df = experiment.fetch_data().df
      df["sem"] = np.nan
      data = Data(df)
      sq_val = df[
          (df["arm_name"] == "status_quo") & (df["metric_name"] == "m1")
      ]["mean"].values[0]
      pareto_arms = sorted(
          df[(df["mean"] <= sq_val) & (df["metric_name"] == "m1")][
              "arm_name"
          ]
          .unique()
          .tolist()
      )
  
      pfrs = get_observed_pareto_frontiers(
          experiment=experiment, data=data
      )
      # We have all pairs of metrics
      self.assertEqual(len(pfrs), 3)
      true_pairs = [("m1", "m2"), ("m1", "m3"), ("m2", "m3")]
      for i, pfr in enumerate(pfrs):
          self.assertEqual(pfr.primary_metric, true_pairs[i][0])
          self.assertEqual(pfr.secondary_metric, true_pairs[i][1])
          self.assertEqual(pfr.absolute_metrics, ["m3"])
          self.assertEqual(list(pfr.means.keys()), ["m1", "m2", "m3"])
          self.assertEqual(len(pfr.means["m1"]), len(pareto_arms))
          self.assertTrue(np.isnan(pfr.sems["m1"]).all())
          self.assertEqual(
              len(pfr.arm_names), len(pareto_arms)
          )  # pyre-ignore
          self.assertEqual(
              pfr.objective_thresholds,
              {"m1": 0, "m2": -100, "m3": 1000},
          )
          arm_idx = np.argsort(pfr.arm_names)
          for i, idx in enumerate(arm_idx):
              name = pareto_arms[i]
              self.assertEqual(pfr.arm_names[idx], name)  # pyre-ignore
              self.assertEqual(
                  pfr.param_dicts[idx],
                  experiment.arms_by_name[name].parameters,
              )
      pfrs = get_observed_pareto_frontiers(
          experiment=experiment, data=data, rel=True
      )
      pfr = pfrs[0]
      self.assertEqual(pfr.absolute_metrics, [])
      self.assertEqual(
          pfr.objective_thresholds,
          {"m1": 0, "m2": -100, "m3": (1000 / sq_val - 1) * 100},
      )
      pfrs = get_observed_pareto_frontiers(
          experiment=experiment, data=data, rel=False
      )
      pfr = pfrs[0]
      self.assertEqual(pfr.absolute_metrics, ["m1", "m2", "m3"])
      self.assertEqual(
          pfr.objective_thresholds, {"m1": sq_val, "m2": 0, "m3": 1000}
      )
      pfrs = get_observed_pareto_frontiers(
          experiment=experiment, data=data, arm_names=["0_1"]
      )
      for pfr in pfrs:
          self.assertTrue("status_quo" in pfr.arm_names)  # pyre-ignore
  
      # Test with missing objective thresholds.
      optimization_config._objective_thresholds = []
      with self.assertRaisesRegex(UserInputError, "`rel` must be"):
          get_observed_pareto_frontiers(
              experiment=experiment, data=data
          )
      pfr = get_observed_pareto_frontiers(
          experiment=experiment, data=data, rel=False
      )[0]
      self.assertEqual(pfr.absolute_metrics, ["m1", "m2", "m3"])
      self.assertEqual(pfr.primary_metric, "m1")
      self.assertEqual(pfr.secondary_metric, "m2")
      self.assertEqual(
          len(pfr.means["m1"]), sum(df["metric_name"] == "m1")
      )
      self.assertEqual(pfr.objective_thresholds, {})
      pfr = get_observed_pareto_frontiers(
          experiment=experiment, data=data, rel=True
      )[0]
      self.assertEqual(pfr.absolute_metrics, [])
  
imports: import copy
  from unittest import mock
  from unittest.mock import patch
  import numpy
  import torch
  from ax.core.data import Data
  from ax.core.objective import MultiObjective, Objective
  from ax.core.observation import Observation, ObservationData, ObservationFeatures
  from ax.core.optimization_config import MultiObjectiveOptimizationConfig
  from ax.core.outcome_constraint import ObjectiveThreshold
  from ax.core.search_space import SearchSpace
  from ax.core.types import ComparisonOp
  from ax.exceptions.core import UserInputError
  from ax.metrics.branin import BraninMetric, NegativeBraninMetric
  from ax.modelbridge.registry import Models
  from ax.plot.pareto_frontier import interact_multiple_pareto_frontier, interact_pareto_frontier
  from ax.plot.pareto_utils import _extract_observed_pareto_2d, get_observed_pareto_frontiers, infer_reference_point_from_experiment, logger, to_nonrobust_search_space
  from ax.utils.common.testutils import TestCase
  from ax.utils.testing.core_stubs import get_branin_experiment, get_branin_experiment_with_multi_objective, get_experiment_with_observations, get_robust_search_space_environmental, get_search_space
label_desc: Use image node_id 2 for calling the ParetoUtilsTest obj's underlying member method code with example usage: obj.test_get_observed_pareto_frontiers() without return types