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: Evaluate qProbabilityOfImprovement per sample on the candidate set `X`.
  
  Args:
      obj: A `sample_shape x batch_shape x q`-dim Tensor of MC objective values.
  
  Returns:
      A `sample_shape x batch_shape x q`-dim Tensor of improvement indicators.
docstr_tok: ["Evaluate","qProbabilityOfImprovement","per","sample","on","the","candidate","set","`","X","`",".","Args",":","obj",":","A","`","sample_shape","x","batch_shape","x","q","`","-dim","Tensor","of","MC","objective","values",".","Returns",":","A","`","sample_shape","x","batch_shape","x","q","`","-dim","Tensor","of","improvement","indicators","."]
code: def _sample_forward(self, obj: Tensor) -> Tensor:
      r"""Evaluate qProbabilityOfImprovement per sample on the candidate set `X`.
  
      Args:
          obj: A `sample_shape x batch_shape x q`-dim Tensor of MC objective values.
  
      Returns:
          A `sample_shape x batch_shape x q`-dim Tensor of improvement indicators.
      """
      improvement = obj - self.best_f.to(obj)
      return torch.sigmoid(improvement / self.tau)
  
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 2 for calling the qProbabilityOfImprovement obj's underlying member method code with example usage: obj._sample_forward(obj) and returns: torch