docstr: Initialize a mixin that contains functions for the batched Pareto-frontier
  partitioning used by the noisy hypervolume-improvement-based acquisition
  functions, i.e. qNEHVI and qLogNEHVI.
  
  Args:
      model: A fitted model.
      ref_point: A list or tensor with `m` elements representing the reference
          point (in the outcome space) w.r.t. to which compute the hypervolume.
          This is a reference point for the objective values (i.e. after
          applying `objective` to the samples).
      X_baseline: A `r x d`-dim Tensor of `r` design points that have already
          been observed. These points are considered as potential approximate
          pareto-optimal design points.
      sampler: The sampler used to draw base samples. If not given,
          a sampler is generated using `get_sampler`. NOTE: A box decomposition is
          of the Pareto front is created for each MC sample, an operation that
          scales as `O(n^m)` and thus becomes particularly costly for `m` > 2.
      objective: The MCMultiOutputObjective under which the samples are
          evaluated. Defaults to `IdentityMCMultiOutputObjective()`.
      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. The acqusition function will compute expected feasible
          hypervolume.
      X_pending: A `batch_shape x m x d`-dim Tensor of `m` design points that
          have points that have been submitted for function evaluation, but
          have not yet been evaluated.
      prune_baseline: If True, remove points in `X_baseline` that are
          highly unlikely to be the pareto optimal and better than the
          reference point. This can significantly improve computation time and
          is generally recommended. In order to customize pruning parameters,
          instead manually call `prune_inferior_points_multi_objective` on
          `X_baseline` before instantiating the acquisition function.
      alpha: The hyperparameter controlling the approximate non-dominated
          partitioning. The default value of 0.0 means an exact partitioning
          is used. As the number of objectives `m` increases, consider increasing
          this parameter in order to limit computational complexity.
      cache_pending: A boolean indicating whether to use cached box
          decompositions (CBD) for handling pending points. This is
          generally recommended.
      max_iep: The maximum number of pending points before the box
          decompositions will be recomputed.
      incremental_nehvi: A boolean indicating whether to compute the
          incremental NEHVI from the `i`th point where `i=1, ..., q`
          under sequential greedy optimization, or the full qNEHVI over
          `q` points.
      cache_root: A boolean indicating whether to cache the root
          decomposition over `X_baseline` and use low-rank updates.
      marginalize_dim: A batch dimension that should be marginalized. For example,
          this is useful when using a batched fully Bayesian model.
docstr_tok: ["Initialize","a","mixin","that","contains","functions","for","the","batched","Pareto-frontier","partitioning","used","by","the","noisy","hypervolume-improvement-based","acquisition","functions",",","i.e",".","qNEHVI","and","qLogNEHVI",".","Args",":","model",":","A","fitted","model",".","ref_point",":","A","list","or","tensor","with","`","m","`","elements","representing","the","reference","point","(","in","the","outcome","space",")","w.r.t",".","to","which","compute","the","hypervolume",".","This","is","a","reference","point","for","the","objective","values","(","i.e",".","after","applying","`","objective","`","to","the","samples",")",".","X_baseline",":","A","`","r","x","d","`","-dim","Tensor","of","`","r","`","design","points","that","have","already","been","observed",".","These","points","are","considered","as","potential","approximate","pareto-optimal","design","points",".","sampler",":","The","sampler","used","to","draw","base","samples",".","If","not","given",",","a","sampler","is","generated","using","`","get_sampler","`",".","NOTE",":","A","box","decomposition","is","of","the","Pareto","front","is","created","for","each","MC","sample",",","an","operation","that","scales","as","`","O","(","n^m",")","`","and","thus","becomes","particularly","costly","for","`","m","`",">","2.","objective",":","The","MCMultiOutputObjective","under","which","the","samples","are","evaluated",".","Defaults","to","`","IdentityMCMultiOutputObjective","(",")","`",".","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",".","The","acqusition","function","will","compute","expected","feasible","hypervolume",".","X_pending",":","A","`","batch_shape","x","m","x","d","`","-dim","Tensor","of","`","m","`","design","points","that","have","points","that","have","been","submitted","for","function","evaluation",",","but","have","not","yet","been","evaluated",".","prune_baseline",":","If","True",",","remove","points","in","`","X_baseline","`","that","are","highly","unlikely","to","be","the","pareto","optimal","and","better","than","the","reference","point",".","This","can","significantly","improve","computation","time","and","is","generally","recommended",".","In","order","to","customize","pruning","parameters",",","instead","manually","call","`","prune_inferior_points_multi_objective","`","on","`","X_baseline","`","before","instantiating","the","acquisition","function",".","alpha",":","The","hyperparameter","controlling","the","approximate","non-dominated","partitioning",".","The","default","value","of","0.0","means","an","exact","partitioning","is","used",".","As","the","number","of","objectives","`","m","`","increases",",","consider","increasing","this","parameter","in","order","to","limit","computational","complexity",".","cache_pending",":","A","boolean","indicating","whether","to","use","cached","box","decompositions","(","CBD",")","for","handling","pending","points",".","This","is","generally","recommended",".","max_iep",":","The","maximum","number","of","pending","points","before","the","box","decompositions","will","be","recomputed",".","incremental_nehvi",":","A","boolean","indicating","whether","to","compute","the","incremental","NEHVI","from","the","`","i","`","th","point","where","`","i=1",",","...",",","q","`","under","sequential","greedy","optimization",",","or","the","full","qNEHVI","over","`","q","`","points",".","cache_root",":","A","boolean","indicating","whether","to","cache","the","root","decomposition","over","`","X_baseline","`","and","use","low-rank","updates",".","marginalize_dim",":","A","batch","dimension","that","should","be","marginalized",".","For","example",",","this","is","useful","when","using","a","batched","fully","Bayesian","model","."]
code: def __init__(
      self,
      model: Model,
      ref_point: Union[List[float], Tensor],
      X_baseline: Tensor,
      sampler: Optional[MCSampler] = None,
      objective: Optional[MCMultiOutputObjective] = None,
      constraints: Optional[List[Callable[[Tensor], Tensor]]] = None,
      X_pending: Optional[Tensor] = None,
      prune_baseline: bool = False,
      alpha: float = 0.0,
      cache_pending: bool = True,
      max_iep: int = 0,
      incremental_nehvi: bool = True,
      cache_root: bool = True,
      marginalize_dim: Optional[int] = None,
  ):
      """Initialize a mixin that contains functions for the batched Pareto-frontier
      partitioning used by the noisy hypervolume-improvement-based acquisition
      functions, i.e. qNEHVI and qLogNEHVI.
  
      Args:
          model: A fitted model.
          ref_point: A list or tensor with `m` elements representing the reference
              point (in the outcome space) w.r.t. to which compute the hypervolume.
              This is a reference point for the objective values (i.e. after
              applying `objective` to the samples).
          X_baseline: A `r x d`-dim Tensor of `r` design points that have already
              been observed. These points are considered as potential approximate
              pareto-optimal design points.
          sampler: The sampler used to draw base samples. If not given,
              a sampler is generated using `get_sampler`. NOTE: A box decomposition is
              of the Pareto front is created for each MC sample, an operation that
              scales as `O(n^m)` and thus becomes particularly costly for `m` > 2.
          objective: The MCMultiOutputObjective under which the samples are
              evaluated. Defaults to `IdentityMCMultiOutputObjective()`.
          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. The acqusition function will compute expected feasible
              hypervolume.
          X_pending: A `batch_shape x m x d`-dim Tensor of `m` design points that
              have points that have been submitted for function evaluation, but
              have not yet been evaluated.
          prune_baseline: If True, remove points in `X_baseline` that are
              highly unlikely to be the pareto optimal and better than the
              reference point. This can significantly improve computation time and
              is generally recommended. In order to customize pruning parameters,
              instead manually call `prune_inferior_points_multi_objective` on
              `X_baseline` before instantiating the acquisition function.
          alpha: The hyperparameter controlling the approximate non-dominated
              partitioning. The default value of 0.0 means an exact partitioning
              is used. As the number of objectives `m` increases, consider increasing
              this parameter in order to limit computational complexity.
          cache_pending: A boolean indicating whether to use cached box
              decompositions (CBD) for handling pending points. This is
              generally recommended.
          max_iep: The maximum number of pending points before the box
              decompositions will be recomputed.
          incremental_nehvi: A boolean indicating whether to compute the
              incremental NEHVI from the `i`th point where `i=1, ..., q`
              under sequential greedy optimization, or the full qNEHVI over
              `q` points.
          cache_root: A boolean indicating whether to cache the root
              decomposition over `X_baseline` and use low-rank updates.
          marginalize_dim: A batch dimension that should be marginalized. For example,
              this is useful when using a batched fully Bayesian model.
      """
      super().__init__(
          model=model, cache_root=cache_root, sampler=sampler
      )
      if len(ref_point) < 2:
          raise ValueError(
              "NoisyExpectedHypervolumeMixin supports m>=2 outcomes "
              f"but ref_point has length {len(ref_point)}, which is smaller than 2."
          )
      tkwargs = {"dtype": X_baseline.dtype, "device": X_baseline.device}
      ref_point = torch.as_tensor(ref_point, **tkwargs)
      self.register_buffer("ref_point", ref_point)
  
      if X_baseline.ndim > 2:
          raise UnsupportedError(
              f"NoisyExpectedHypervolumeMixin does not support batched "
              f"X_baseline. Expected 2 dims, got {X_baseline.ndim}."
          )
      if prune_baseline:
          X_baseline = prune_inferior_points_multi_objective(
              model=model,
              X=X_baseline,
              objective=objective,
              constraints=constraints,
              ref_point=ref_point,
              marginalize_dim=marginalize_dim,
          )
  
      self.alpha = alpha
      self.q_in = -1
      self.q_out = -1
  
      self.partitioning = None
      # set partitioning class and args
      self.p_kwargs = {}
      if self.alpha > 0:
          self.p_kwargs["alpha"] = self.alpha
          self.p_class = NondominatedPartitioning
      else:
          self.p_class = FastNondominatedPartitioning
      self.register_buffer("_X_baseline", X_baseline)
      self.register_buffer("_X_baseline_and_pending", X_baseline)
      self.register_buffer(
          "cache_pending",
          torch.tensor(cache_pending, dtype=bool),
      )
      self.register_buffer(
          "_prev_nehvi",
          torch.tensor(0.0, **tkwargs),
      )
      self.register_buffer(
          "_max_iep",
          torch.tensor(max_iep, dtype=torch.long),
      )
      self.register_buffer(
          "incremental_nehvi",
          torch.tensor(incremental_nehvi, dtype=torch.bool),
      )
      # Base sampler is initialized in _set_cell_bounds.
      self.base_sampler = None
  
      # is this called twice, once here, once in MultiObjectiveMCAcquisitionFunction?
      if X_pending is not None:
          # This will call self._set_cell_bounds if the number of pending
          # points is greater than self._max_iep.
          self.set_X_pending(X_pending)
      # In the case that X_pending is not None, but there are fewer than
      # max_iep pending points, the box decompositions are not performed in
      # set_X_pending. Therefore, we need to perform a box decomposition over
      # f(X_baseline) here.
      if X_pending is None or X_pending.shape[-2] <= self._max_iep:
          self._set_cell_bounds(num_new_points=X_baseline.shape[0])
  
      # Set q_in=-1 to so that self.sampler is updated at the next forward call.
      self.q_in = -1
  
imports: from __future__ import annotations
  import warnings
  from copy import deepcopy
  from itertools import combinations
  from typing import Callable, List, Optional, Union
  import torch
  from botorch.acquisition.cached_cholesky import CachedCholeskyMCSamplerMixin
  from botorch.acquisition.multi_objective.objective import MCMultiOutputObjective
  from botorch.acquisition.multi_objective.utils import prune_inferior_points_multi_objective
  from botorch.exceptions.errors import BotorchError, BotorchTensorDimensionError, UnsupportedError
  from botorch.exceptions.warnings import BotorchWarning
  from botorch.models.model import Model
  from botorch.sampling.base import MCSampler
  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.box_decompositions.non_dominated import FastNondominatedPartitioning, NondominatedPartitioning
  from botorch.utils.multi_objective.box_decompositions.utils import _pad_batch_pareto_frontier
  from botorch.utils.objective import compute_feasibility_indicator
  from botorch.utils.torch import BufferDict
  from torch import Tensor
label_desc: Use image node_id 1 to create a new NoisyExpectedHypervolumeMixin object from inherited base classes: CachedCholeskyMCSamplerMixin with example: obj = NoisyExpectedHypervolumeMixin(model, ref_point, X_baseline, sampler, objective, constraints, X_pending, prune_baseline, alpha, cache_pending, max_iep, incremental_nehvi, cache_root, marginalize_dim)