class_docstr: The acquisition function for Max-value Entropy Search.
  
  This acquisition function computes the mutual information of max values and
  a candidate point X. See [Wang2017mves]_ for a detailed discussion.
  
  The model must be single-outcome. The batch case `q > 1` is supported
  through cyclic optimization and fantasies.
  
  Example:
      >>> model = SingleTaskGP(train_X, train_Y)
      >>> candidate_set = torch.rand(1000, bounds.size(1))
      >>> candidate_set = bounds[0] + (bounds[1] - bounds[0]) * candidate_set
      >>> MES = qMaxValueEntropy(model, candidate_set)
      >>> mes = MES(test_X)
docstr: Single-outcome max-value entropy search acquisition function.
  
  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_fantasies: Number of fantasies to generate. The higher this
          number the more accurate the model (at the expense of model
          complexity, wall time and memory). Ignored if `X_pending` is `None`.
      num_mv_samples: Number of max value samples.
      num_y_samples: Number of posterior samples at specific design point `X`.
      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","max-value","entropy","search","acquisition","function",".","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_fantasies",":","Number","of","fantasies","to","generate",".","The","higher","this","number","the","more","accurate","the","model","(","at","the","expense","of","model","complexity",",","wall","time","and","memory",")",".","Ignored","if","`","X_pending","`","is","`","None","`",".","num_mv_samples",":","Number","of","max","value","samples",".","num_y_samples",":","Number","of","posterior","samples","at","specific","design","point","`","X","`",".","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_fantasies: int = 16,
      num_mv_samples: int = 10,
      num_y_samples: int = 128,
      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 max-value entropy search acquisition function.
  
      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_fantasies: Number of fantasies to generate. The higher this
              number the more accurate the model (at the expense of model
              complexity, wall time and memory). Ignored if `X_pending` is `None`.
          num_mv_samples: Number of max value samples.
          num_y_samples: Number of posterior samples at specific design point `X`.
          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.
      """
      super().__init__(
          model=model,
          candidate_set=candidate_set,
          num_mv_samples=num_mv_samples,
          posterior_transform=posterior_transform,
          use_gumbel=use_gumbel,
          maximize=maximize,
          X_pending=X_pending,
          train_inputs=train_inputs,
      )
      MCSamplerMixin.__init__(
          self,
          sampler=SobolQMCNormalSampler(
              sample_shape=torch.Size([num_y_samples])
          ),
      )
      self._init_model = (
          model  # used for `fantasize()` when setting `X_pending`
      )
      self.fantasies_sampler = SobolQMCNormalSampler(
          sample_shape=torch.Size([num_fantasies])
      )
      self.num_fantasies = num_fantasies
      self.set_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 qMaxValueEntropy object from inherited base classes: DiscreteMaxValueBase, MCSamplerMixin with example: obj = qMaxValueEntropy(model, candidate_set, num_fantasies, num_mv_samples, num_y_samples, posterior_transform, use_gumbel, maximize, X_pending, train_inputs)