class_docstr: MC-based batch Expected Improvement.
  
  This computes qEI by
  (1) sampling the joint posterior over q points
  (2) evaluating the improvement over the current best for each sample
  (3) maximizing over q
  (4) averaging over the samples
  
  `qEI(X) = E(max(max Y - best_f, 0)), Y ~ f(X), where X = (x_1,...,x_q)`
  
  Example:
      >>> model = SingleTaskGP(train_X, train_Y)
      >>> best_f = train_Y.max()[0]
      >>> sampler = SobolQMCNormalSampler(1024)
      >>> qEI = qExpectedImprovement(model, best_f, sampler)
      >>> qei = qEI(test_X)
class_docstr_tok: ["MC-based","batch","Expected","Improvement",".","This","computes","qEI","by","(","1",")","sampling","the","joint","posterior","over","q","points","(","2",")","evaluating","the","improvement","over","the","current","best","for","each","sample","(","3",")","maximizing","over","q","(","4",")","averaging","over","the","samples","`","qEI","(","X",")","=","E","(","max","(","max","Y","-","best_f",",","0",")",")",",","Y","~","f","(","X",")",",","where","X","=","(","x_1",",","...",",","x_q",")","`","Example",":",">",">",">","model","=","SingleTaskGP","(","train_X",",","train_Y",")",">",">",">","best_f","=","train_Y.max","(",")","[","0","]",">",">",">","sampler","=","SobolQMCNormalSampler","(","1024",")",">",">",">","qEI","=","qExpectedImprovement","(","model",",","best_f",",","sampler",")",">",">",">","qei","=","qEI","(","test_X",")"]
docstr: q-Expected 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 been
          submitted for function evaluation but have not yet been evaluated.
          Concatenated into X upon forward call. Copied and set to have no
          gradient.
      constraints: A list of constraint callables which map a Tensor of posterior
          samples of dimension `sample_shape x batch-shape x q x m`-dim to a
          `sample_shape x batch-shape x q`-dim Tensor. The associated constraints
          are considered satisfied if the output 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-Expected","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","been","submitted","for","function","evaluation","but","have","not","yet","been","evaluated",".","Concatenated","into","X","upon","forward","call",".","Copied","and","set","to","have","no","gradient",".","constraints",":","A","list","of","constraint","callables","which","map","a","Tensor","of","posterior","samples","of","dimension","`","sample_shape","x","batch-shape","x","q","x","m","`","-dim","to","a","`","sample_shape","x","batch-shape","x","q","`","-dim","Tensor",".","The","associated","constraints","are","considered","satisfied","if","the","output","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,
      constraints: Optional[List[Callable[[Tensor], Tensor]]] = None,
      eta: Union[Tensor, float] = 1e-3,
  ) -> None:
      r"""q-Expected 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 been
              submitted for function evaluation but have not yet been evaluated.
              Concatenated into X upon forward call. Copied and set to have no
              gradient.
          constraints: A list of constraint callables which map a Tensor of posterior
              samples of dimension `sample_shape x batch-shape x q x m`-dim to a
              `sample_shape x batch-shape x q`-dim Tensor. The associated constraints
              are considered satisfied if the output 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,
      )
      self.register_buffer(
          "best_f", torch.as_tensor(best_f, 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 qExpectedImprovement object from inherited base classes: SampleReducingMCAcquisitionFunction with example: obj = qExpectedImprovement(model, best_f, sampler, objective, posterior_transform, X_pending, constraints, eta)