class_docstr: Abstract base class for MES-like methods using discrete max posterior sampling.
  
  This class provides basic functionality for sampling posterior maximum values from
  a surrogate Gaussian process model using a discrete set of candidates. It supports
  either exact (w.r.t. the candidate set) sampling, or using a Gumbel approximation.
docstr: Single-outcome MES-like acquisition functions based on discrete MV sampling.
  
  Args:
      model: A fitted single-outcome model.
      candidate_set: A `n x d` Tensor including `n` candidate points to
          discretize the design space. Max values are sampled from the
          (joint) model posterior over these points.
      num_mv_samples: Number of max value samples.
      posterior_transform: A PosteriorTransform. If using a multi-output model,
          a PosteriorTransform that transforms the multi-output posterior into a
          single-output posterior is required.
      use_gumbel: If True, use Gumbel approximation to sample the max values.
      maximize: If True, consider the problem a maximization problem.
      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.
      train_inputs: A `n_train x d` Tensor that the model has been fitted on.
          Not required if the model is an instance of a GPyTorch ExactGP model.
docstr_tok: ["Single-outcome","MES-like","acquisition","functions","based","on","discrete","MV","sampling",".","Args",":","model",":","A","fitted","single-outcome","model",".","candidate_set",":","A","`","n","x","d","`","Tensor","including","`","n","`","candidate","points","to","discretize","the","design","space",".","Max","values","are","sampled","from","the","(","joint",")","model","posterior","over","these","points",".","num_mv_samples",":","Number","of","max","value","samples",".","posterior_transform",":","A","PosteriorTransform",".","If","using","a","multi-output","model",",","a","PosteriorTransform","that","transforms","the","multi-output","posterior","into","a","single-output","posterior","is","required",".","use_gumbel",":","If","True",",","use","Gumbel","approximation","to","sample","the","max","values",".","maximize",":","If","True",",","consider","the","problem","a","maximization","problem",".","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",".","train_inputs",":","A","`","n_train","x","d","`","Tensor","that","the","model","has","been","fitted","on",".","Not","required","if","the","model","is","an","instance","of","a","GPyTorch","ExactGP","model","."]
code: def __init__(
      self,
      model: Model,
      candidate_set: Tensor,
      num_mv_samples: int = 10,
      posterior_transform: Optional[PosteriorTransform] = None,
      use_gumbel: bool = True,
      maximize: bool = True,
      X_pending: Optional[Tensor] = None,
      train_inputs: Optional[Tensor] = None,
  ) -> None:
      r"""Single-outcome MES-like acquisition functions based on discrete MV sampling.
  
      Args:
          model: A fitted single-outcome model.
          candidate_set: A `n x d` Tensor including `n` candidate points to
              discretize the design space. Max values are sampled from the
              (joint) model posterior over these points.
          num_mv_samples: Number of max value samples.
          posterior_transform: A PosteriorTransform. If using a multi-output model,
              a PosteriorTransform that transforms the multi-output posterior into a
              single-output posterior is required.
          use_gumbel: If True, use Gumbel approximation to sample the max values.
          maximize: If True, consider the problem a maximization problem.
          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.
          train_inputs: A `n_train x d` Tensor that the model has been fitted on.
              Not required if the model is an instance of a GPyTorch ExactGP model.
      """
      self.use_gumbel = use_gumbel
  
      if train_inputs is None and hasattr(model, "train_inputs"):
          train_inputs = model.train_inputs[0]
      if train_inputs is not None:
          if train_inputs.ndim > 2:
              raise NotImplementedError(
                  "Batch GP models (e.g. fantasized models) "
                  "are not yet supported by `MaxValueBase`"
              )
          train_inputs = match_batch_shape(train_inputs, candidate_set)
          candidate_set = torch.cat(
              [candidate_set, train_inputs], dim=0
          )
  
      self.candidate_set = candidate_set
  
      super().__init__(
          model=model,
          num_mv_samples=num_mv_samples,
          posterior_transform=posterior_transform,
          maximize=maximize,
          X_pending=X_pending,
      )
  
imports: from __future__ import annotations
  from abc import ABC, abstractmethod
  from copy import deepcopy
  from math import log
  from typing import Any, Callable, Optional
  import numpy
  import torch
  from botorch.acquisition.acquisition import AcquisitionFunction, MCSamplerMixin
  from botorch.acquisition.cost_aware import CostAwareUtility, InverseCostWeightedUtility
  from botorch.acquisition.objective import PosteriorTransform
  from botorch.exceptions.errors import UnsupportedError
  from botorch.models.cost import AffineFidelityCostModel
  from botorch.models.model import Model
  from botorch.models.utils import check_no_nans
  from botorch.sampling.normal import SobolQMCNormalSampler
  from botorch.utils.transforms import match_batch_shape, t_batch_mode_transform
  from linear_operator.functions import inv_quad
  from linear_operator.utils.cholesky import psd_safe_cholesky
  from scipy.optimize import brentq
  from scipy.stats import norm
  from torch import Tensor
label_desc: Use image node_id 1 to create a new DiscreteMaxValueBase object from inherited base classes: MaxValueBase with example: obj = DiscreteMaxValueBase(model, candidate_set, num_mv_samples, posterior_transform, use_gumbel, maximize, X_pending, train_inputs)