code: def prune_inferior_points_multi_objective(
      model: Model,
      X: Tensor,
      ref_point: Tensor,
      objective: Optional[MCMultiOutputObjective] = None,
      constraints: Optional[List[Callable[[Tensor], Tensor]]] = None,
      num_samples: int = 2048,
      max_frac: float = 1.0,
      marginalize_dim: Optional[int] = None,
  ) -> Tensor:
      r"""Prune points from an input tensor that are unlikely to be pareto optimal.
  
      Given a model, an objective, and an input tensor `X`, this function returns
      the subset of points in `X` that have some probability of being pareto
      optimal, better than the reference point, and feasible. This function uses
      sampling to estimate the probabilities, the higher the number of points `n`
      in `X` the higher the number of samples `num_samples` should be to obtain
      accurate estimates.
  
      Args:
          model: A fitted model. Batched models are currently not supported.
          X: An input tensor of shape `n x d`. Batched inputs are currently not
              supported.
          ref_point: The reference point.
          objective: The objective under which to evaluate the posterior.
          constraints: A list of callables, each mapping a Tensor of dimension
              `sample_shape x batch-shape x q x m` to a Tensor of dimension
              `sample_shape x batch-shape x q`, where negative values imply
              feasibility.
          num_samples: The number of samples used to compute empirical
              probabilities of being the best point.
          max_frac: The maximum fraction of points to retain. Must satisfy
              `0 < max_frac <= 1`. Ensures that the number of elements in the
              returned tensor does not exceed `ceil(max_frac * n)`.
          marginalize_dim: A batch dimension that should be marginalized.
              For example, this is useful when using a batched fully Bayesian
              model.
  
      Returns:
          A `n' x d` with subset of points in `X`, where
  
              n' = min(N_nz, ceil(max_frac * n))
  
          with `N_nz` the number of points in `X` that have non-zero (empirical,
          under `num_samples` samples) probability of being pareto optimal.
      """
      if marginalize_dim is None and is_ensemble(model):
          # TODO: Properly deal with marginalizing fully Bayesian models
          marginalize_dim = MCMC_DIM
  
      if X.ndim > 2:
          # TODO: support batched inputs (req. dealing with ragged tensors)
          raise UnsupportedError(
              "Batched inputs `X` are currently unsupported by "
              "prune_inferior_points_multi_objective"
          )
      max_points = math.ceil(max_frac * X.size(-2))
      if max_points < 1 or max_points > X.size(-2):
          raise ValueError(
              f"max_frac must take values in (0, 1], is {max_frac}"
          )
      with torch.no_grad():
          posterior = model.posterior(X=X)
      sampler = get_sampler(
          posterior, sample_shape=torch.Size([num_samples])
      )
      samples = sampler(posterior)
      if objective is None:
          objective = IdentityMCMultiOutputObjective()
      obj_vals = objective(samples, X=X)
      if obj_vals.ndim > 3:
          if obj_vals.ndim == 4 and marginalize_dim is not None:
              obj_vals = obj_vals.mean(dim=marginalize_dim)
          else:
              # TODO: support batched inputs (req. dealing with ragged tensors)
              raise UnsupportedError(
                  "Models with multiple batch dims are currently unsupported by"
                  " prune_inferior_points_multi_objective."
              )
      infeas = ~compute_feasibility_indicator(
          constraints=constraints,
          samples=samples,
          marginalize_dim=marginalize_dim,
      )
      if infeas.any():
          obj_vals[infeas] = ref_point
      pareto_mask = is_non_dominated(obj_vals, deduplicate=False) & (
          obj_vals > ref_point
      ).all(dim=-1)
      probs = pareto_mask.to(dtype=X.dtype).mean(dim=0)
      idcs = probs.nonzero().view(-1)
      if idcs.shape[0] > max_points:
          counts, order_idcs = torch.sort(probs, descending=True)
          idcs = order_idcs[:max_points]
      effective_n_w = obj_vals.shape[-2] // X.shape[-2]
      idcs = (idcs / effective_n_w).long().unique()
      return X[idcs]
  
imports: from __future__ import annotations
  import math
  import warnings
  from math import ceil
  from typing import Any, Callable, Dict, List, Optional, Tuple
  import torch
  from botorch.acquisition import monte_carlo
  from botorch.acquisition.multi_objective.objective import IdentityMCMultiOutputObjective, MCMultiOutputObjective
  from botorch.exceptions.errors import UnsupportedError
  from botorch.exceptions.warnings import BotorchWarning
  from botorch.models.deterministic import GenericDeterministicModel
  from botorch.models.fully_bayesian import MCMC_DIM
  from botorch.models.model import Model
  from botorch.sampling.get_sampler import get_sampler
  from botorch.utils.gp_sampling import get_gp_samples
  from botorch.utils.multi_objective.box_decompositions.box_decomposition import BoxDecomposition
  from botorch.utils.multi_objective.box_decompositions.box_decomposition_list import BoxDecompositionList
  from botorch.utils.multi_objective.box_decompositions.dominated import DominatedPartitioning
  from botorch.utils.multi_objective.pareto import is_non_dominated
  from botorch.utils.objective import compute_feasibility_indicator
  from botorch.utils.sampling import draw_sobol_samples
  from botorch.utils.transforms import is_ensemble
  from torch import Tensor
label_desc: Use image node_id 2 for calling a global function with example usage: prune_inferior_points_multi_objective(model, X, ref_point, objective, constraints, num_samples, max_frac, marginalize_dim) and returns: X