class_docstr: MC-based batch Probability of Improvement.
  
  Estimates the probability of improvement over the current best observed
  value by sampling from the joint posterior distribution of the q-batch.
  MC-based estimates of a probability involves taking expectation of an
  indicator function; to support auto-differentiation, the indicator is
  replaced with a sigmoid function with temperature parameter `tau`.
  
  `qPI(X) = P(max Y >= best_f), Y ~ f(X), X = (x_1,...,x_q)`
  
  Example:
      >>> model = SingleTaskGP(train_X, train_Y)
      >>> best_f = train_Y.max()[0]
      >>> sampler = SobolQMCNormalSampler(1024)
      >>> qPI = qProbabilityOfImprovement(model, best_f, sampler)
      >>> qpi = qPI(test_X)
class_docstr_tok: ["MC-based","batch","Probability","of","Improvement",".","Estimates","the","probability","of","improvement","over","the","current","best","observed","value","by","sampling","from","the","joint","posterior","distribution","of","the","q-batch",".","MC-based","estimates","of","a","probability","involves","taking","expectation","of","an","indicator","function",";","to","support","auto-differentiation",",","the","indicator","is","replaced","with","a","sigmoid","function","with","temperature","parameter","`","tau","`",".","`","qPI","(","X",")","=","P","(","max","Y",">","=","best_f",")",",","Y","~","f","(","X",")",",","X","=","(","x_1",",","...",",","x_q",")","`","Example",":",">",">",">","model","=","SingleTaskGP","(","train_X",",","train_Y",")",">",">",">","best_f","=","train_Y.max","(",")","[","0","]",">",">",">","sampler","=","SobolQMCNormalSampler","(","1024",")",">",">",">","qPI","=","qProbabilityOfImprovement","(","model",",","best_f",",","sampler",")",">",">",">","qpi","=","qPI","(","test_X",")"]
docstr: q-Probability of Improvement.
  
  Args:
      model: A fitted model.
      best_f: The best objective value observed so far (assumed noiseless). Can
          be a `batch_shape`-shaped tensor, which in case of a batched model
          specifies potentially different values for each element of the batch.
      sampler: The sampler used to draw base samples. See `MCAcquisitionFunction`
          more details.
      objective: The MCAcquisitionObjective under which the samples are
          evaluated. Defaults to `IdentityMCObjective()`.
          NOTE: `ConstrainedMCObjective` for outcome constraints is deprecated in
          favor of passing the `constraints` directly to this constructor.
      posterior_transform: A PosteriorTransform (optional).
      X_pending:  A `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.  Concatenated into X upon
          forward call.  Copied and set to have no gradient.
      tau: The temperature parameter used in the sigmoid approximation
          of the step function. Smaller values yield more accurate
          approximations of the function, but result in gradients
          estimates with higher variance.
      constraints: A list of constraint callables which map posterior samples to
          a scalar. The associated constraint is considered satisfied if this
          scalar is less than zero.
      eta: Temperature parameter(s) governing the smoothness of the sigmoid
          approximation to the constraint indicators. For more details, on this
          parameter, see the docs of `compute_smoothed_feasibility_indicator`.
docstr_tok: ["q-Probability","of","Improvement",".","Args",":","model",":","A","fitted","model",".","best_f",":","The","best","objective","value","observed","so","far","(","assumed","noiseless",")",".","Can","be","a","`","batch_shape","`","-shaped","tensor",",","which","in","case","of","a","batched","model","specifies","potentially","different","values","for","each","element","of","the","batch",".","sampler",":","The","sampler","used","to","draw","base","samples",".","See","`","MCAcquisitionFunction","`","more","details",".","objective",":","The","MCAcquisitionObjective","under","which","the","samples","are","evaluated",".","Defaults","to","`","IdentityMCObjective","(",")","`",".","NOTE",":","`","ConstrainedMCObjective","`","for","outcome","constraints","is","deprecated","in","favor","of","passing","the","`","constraints","`","directly","to","this","constructor",".","posterior_transform",":","A","PosteriorTransform","(","optional",")",".","X_pending",":","A","`","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",".","Concatenated","into","X","upon","forward","call",".","Copied","and","set","to","have","no","gradient",".","tau",":","The","temperature","parameter","used","in","the","sigmoid","approximation","of","the","step","function",".","Smaller","values","yield","more","accurate","approximations","of","the","function",",","but","result","in","gradients","estimates","with","higher","variance",".","constraints",":","A","list","of","constraint","callables","which","map","posterior","samples","to","a","scalar",".","The","associated","constraint","is","considered","satisfied","if","this","scalar","is","less","than","zero",".","eta",":","Temperature","parameter","(","s",")","governing","the","smoothness","of","the","sigmoid","approximation","to","the","constraint","indicators",".","For","more","details",",","on","this","parameter",",","see","the","docs","of","`","compute_smoothed_feasibility_indicator","`","."]
code: def __init__(
      self,
      model: Model,
      best_f: Union[float, Tensor],
      sampler: Optional[MCSampler] = None,
      objective: Optional[MCAcquisitionObjective] = None,
      posterior_transform: Optional[PosteriorTransform] = None,
      X_pending: Optional[Tensor] = None,
      tau: float = 1e-3,
      constraints: Optional[List[Callable[[Tensor], Tensor]]] = None,
      eta: Union[Tensor, float] = 1e-3,
  ) -> None:
      r"""q-Probability of Improvement.
  
      Args:
          model: A fitted model.
          best_f: The best objective value observed so far (assumed noiseless). Can
              be a `batch_shape`-shaped tensor, which in case of a batched model
              specifies potentially different values for each element of the batch.
          sampler: The sampler used to draw base samples. See `MCAcquisitionFunction`
              more details.
          objective: The MCAcquisitionObjective under which the samples are
              evaluated. Defaults to `IdentityMCObjective()`.
              NOTE: `ConstrainedMCObjective` for outcome constraints is deprecated in
              favor of passing the `constraints` directly to this constructor.
          posterior_transform: A PosteriorTransform (optional).
          X_pending:  A `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.  Concatenated into X upon
              forward call.  Copied and set to have no gradient.
          tau: The temperature parameter used in the sigmoid approximation
              of the step function. Smaller values yield more accurate
              approximations of the function, but result in gradients
              estimates with higher variance.
          constraints: A list of constraint callables which map posterior samples to
              a scalar. The associated constraint is considered satisfied if this
              scalar is less than zero.
          eta: Temperature parameter(s) governing the smoothness of the sigmoid
              approximation to the constraint indicators. For more details, on this
              parameter, see the docs of `compute_smoothed_feasibility_indicator`.
      """
      super().__init__(
          model=model,
          sampler=sampler,
          objective=objective,
          posterior_transform=posterior_transform,
          X_pending=X_pending,
          constraints=constraints,
          eta=eta,
      )
      best_f = torch.as_tensor(best_f, dtype=float).unsqueeze(
          -1
      )  # adding batch dim
      self.register_buffer("best_f", best_f)
      self.register_buffer("tau", torch.as_tensor(tau, dtype=float))
  
imports: from __future__ import annotations
  import math
  from abc import ABC, abstractmethod
  from copy import deepcopy
  from functools import partial
  from typing import Callable, List, Optional, Protocol, Tuple, Union
  import torch
  from botorch.acquisition.acquisition import AcquisitionFunction, MCSamplerMixin
  from botorch.acquisition.cached_cholesky import CachedCholeskyMCSamplerMixin
  from botorch.acquisition.objective import ConstrainedMCObjective, IdentityMCObjective, MCAcquisitionObjective, PosteriorTransform
  from botorch.acquisition.utils import compute_best_feasible_objective, prune_inferior_points, repeat_to_match_aug_dim
  from botorch.exceptions.errors import UnsupportedError
  from botorch.models.model import Model
  from botorch.sampling.base import MCSampler
  from botorch.utils.objective import compute_smoothed_feasibility_indicator
  from botorch.utils.transforms import concatenate_pending_points, match_batch_shape, t_batch_mode_transform
  from torch import Tensor
label_desc: Use image node_id 1 to create a new qProbabilityOfImprovement object from inherited base classes: SampleReducingMCAcquisitionFunction with example: obj = qProbabilityOfImprovement(model, best_f, sampler, objective, posterior_transform, X_pending, tau, constraints, eta)