code: def test_prune_inferior_points_multi_objective(self):
      tkwargs = {"device": self.device}
      for dtype in (torch.float, torch.double):
          tkwargs["dtype"] = dtype
          X = torch.rand(3, 2, **tkwargs)
          ref_point = torch.tensor([0.25, 0.25], **tkwargs)
          # the event shape is `q x m` = 3 x 2
          samples = torch.tensor(
              [[1.0, 2.0], [2.0, 1.0], [3.0, 4.0]], **tkwargs
          )
          mm = MockModel(MockPosterior(samples=samples))
          # test that a batched X raises errors
          with self.assertRaises(UnsupportedError):
              prune_inferior_points_multi_objective(
                  model=mm, X=X.expand(2, 3, 2), ref_point=ref_point
              )
          # test that a batched model raises errors (event shape is `q x m` = 3 x m)
          mm2 = MockModel(
              MockPosterior(samples=samples.expand(2, 3, 2))
          )
          with self.assertRaises(UnsupportedError):
              prune_inferior_points_multi_objective(
                  model=mm2, X=X, ref_point=ref_point
              )
          # test that invalid max_frac is checked properly
          with self.assertRaises(ValueError):
              prune_inferior_points_multi_objective(
                  model=mm, X=X, max_frac=1.1, ref_point=ref_point
              )
          # test basic behaviour
          X_pruned = prune_inferior_points_multi_objective(
              model=mm, X=X, ref_point=ref_point
          )
          self.assertTrue(torch.equal(X_pruned, X[[-1]]))
          # test unstd objective
          unstd_obj = UnstandardizeMCMultiOutputObjective(
              Y_mean=samples.mean(dim=0),
              Y_std=samples.std(dim=0),
              outcomes=[0, 1],
          )
          X_pruned = prune_inferior_points_multi_objective(
              model=mm, X=X, ref_point=ref_point, objective=unstd_obj
          )
          self.assertTrue(torch.equal(X_pruned, X[[-1]]))
          # test constraints
          samples_constrained = torch.tensor(
              [[1.0, 2.0, -1.0], [2.0, 1.0, -1.0], [3.0, 4.0, 1.0]],
              **tkwargs,
          )
          mm_constrained = MockModel(
              MockPosterior(samples=samples_constrained)
          )
          X_pruned = prune_inferior_points_multi_objective(
              model=mm_constrained,
              X=X,
              ref_point=ref_point,
              objective=unstd_obj,
              constraints=[lambda Y: Y[..., -1]],
          )
          self.assertTrue(torch.equal(X_pruned, X[:2]))
  
          # test non-repeated samples (requires mocking out MockPosterior's rsample)
          samples = torch.tensor(
              [
                  [[3.0], [0.0], [0.0]],
                  [[0.0], [2.0], [0.0]],
                  [[0.0], [0.0], [1.0]],
              ],
              device=self.device,
              dtype=dtype,
          )
          with mock.patch.object(
              MockPosterior, "rsample", return_value=samples
          ):
              mm = MockModel(MockPosterior(samples=samples))
              X_pruned = prune_inferior_points_multi_objective(
                  model=mm, X=X, ref_point=ref_point
              )
          self.assertTrue(torch.equal(X_pruned, X))
          # test max_frac limiting
          with mock.patch.object(
              MockPosterior, "rsample", return_value=samples
          ):
              mm = MockModel(MockPosterior(samples=samples))
              X_pruned = prune_inferior_points_multi_objective(
                  model=mm, X=X, ref_point=ref_point, max_frac=2 / 3
              )
          if self.device.type == "cuda":
              # sorting has different order on cuda
              self.assertTrue(
                  torch.equal(X_pruned, X[[2, 1]])
                  or torch.equal(X_pruned, X[[1, 2]])
              )
          else:
              self.assertTrue(torch.equal(X_pruned, X[:2]))
          # test that zero-probability is in fact pruned
          samples[2, 0, 0] = 10
          with mock.patch.object(
              MockPosterior, "rsample", return_value=samples
          ):
              mm = MockModel(MockPosterior(samples=samples))
              X_pruned = prune_inferior_points_multi_objective(
                  model=mm, X=X, ref_point=ref_point
              )
          self.assertTrue(torch.equal(X_pruned, X[:2]))
  
          # test marginalize_dim and constraints
          samples = torch.tensor(
              [[1.0, 2.0], [2.0, 1.0], [3.0, 4.0]], **tkwargs
          )
          samples = samples.unsqueeze(-3).expand(
              *samples.shape[:-2],
              2,
              *samples.shape[-2:],
          )
          mm = MockModel(MockPosterior(samples=samples))
          X_pruned = prune_inferior_points_multi_objective(
              model=mm,
              X=X,
              ref_point=ref_point,
              objective=unstd_obj,
              constraints=[lambda Y: Y[..., -1] - 3.0],
              marginalize_dim=-3,
          )
          self.assertTrue(torch.equal(X_pruned, X[:2]))
  
imports: import warnings
  from itertools import product
  from unittest import mock
  import torch
  from botorch.acquisition.multi_objective.objective import MCMultiOutputObjective, UnstandardizeMCMultiOutputObjective
  from botorch.acquisition.multi_objective.utils import compute_sample_box_decomposition, get_default_partitioning_alpha, prune_inferior_points_multi_objective, random_search_optimizer, sample_optimal_points
  from botorch.exceptions.errors import UnsupportedError
  from botorch.models.gp_regression import SingleTaskGP
  from botorch.models.model_list_gp_regression import ModelListGP
  from botorch.models.transforms.outcome import Standardize
  from botorch.utils.gp_sampling import get_gp_samples
  from botorch.utils.multi_objective import is_non_dominated
  from botorch.utils.testing import BotorchTestCase, MockModel, MockPosterior
  from torch import Tensor
label_desc: Use image node_id 2 for calling the TestMultiObjectiveUtils obj's underlying member method code with example usage: obj.test_prune_inferior_points_multi_objective() without return types