class_docstr: MC-based batch acquisition function that reduces across samples and implements
  a general treatment of outcome constraints.
  
  This class's `forward` computes the - possibly constrained - acquisition value by
  (1) computing the unconstrained utility for each MC sample using `_sample_forward`,
  (2) weighing the utility values by the constraint indicator per MC sample, and
  (3) reducing (e.g. averaging) the weighted utility values over the MC dimension.
  
  NOTE: Do *NOT* override the `forward` method, unless you have thought about it well.
  
  `forward` is implemented generically to incorporate constraints in a principled way,
  and takes care of reducing over the Monte Carlo and batch dimensions via the
  `sample_reduction` and `q_reduction` arguments, which default to `torch.mean` and
  `torch.max`, respectively.
  
  In order to implement a custom SampleReducingMCAcquisitionFunction, we only need to
  implement the `_sample_forward(obj: Tensor) -> Tensor` method, which maps objective
  samples to acquisition utility values without reducing the Monte Carlo and batch
  (i.e. q) dimensions (see details in the docstring of `_sample_forward`).
  
  A note on design choices:
  
  The primary purpose of `SampleReducingMCAcquisitionFunction`is to support outcome
  constraints. On the surface, designing a wrapper `ConstrainedMCAcquisitionFunction`
  could be an elegant solution to this end, but it would still require the acquisition
  functions to implement a `_sample_forward` method to weigh acquisition utilities at
  the sample level. Further, `qNoisyExpectedImprovement` is a special case that is
  hard to encompass in this pattern, since it requires the computation of the best
  *feasible* objective, which requires access to the constraint functions. However,
  if the constraints are stored in a wrapper class, they will be inaccessible to the
  forward pass. These problems are circumvented by the design of this class.
class_docstr_tok: ["MC-based","batch","acquisition","function","that","reduces","across","samples","and","implements","a","general","treatment","of","outcome","constraints",".","This","class","'s","`","forward","`","computes","the","-","possibly","constrained","-","acquisition","value","by","(","1",")","computing","the","unconstrained","utility","for","each","MC","sample","using","`","_sample_forward","`",",","(","2",")","weighing","the","utility","values","by","the","constraint","indicator","per","MC","sample",",","and","(","3",")","reducing","(","e.g",".","averaging",")","the","weighted","utility","values","over","the","MC","dimension",".","NOTE",":","Do","*","NOT","*","override","the","`","forward","`","method",",","unless","you","have","thought","about","it","well",".","`","forward","`","is","implemented","generically","to","incorporate","constraints","in","a","principled","way",",","and","takes","care","of","reducing","over","the","Monte","Carlo","and","batch","dimensions","via","the","`","sample_reduction","`","and","`","q_reduction","`","arguments",",","which","default","to","`","torch.mean","`","and","`","torch.max","`",",","respectively",".","In","order","to","implement","a","custom","SampleReducingMCAcquisitionFunction",",","we","only","need","to","implement","the","`","_sample_forward","(","obj",":","Tensor",")","-",">","Tensor","`","method",",","which","maps","objective","samples","to","acquisition","utility","values","without","reducing","the","Monte","Carlo","and","batch","(","i.e",".","q",")","dimensions","(","see","details","in","the","docstring","of","`","_sample_forward","`",")",".","A","note","on","design","choices",":","The","primary","purpose","of","`","SampleReducingMCAcquisitionFunction","`","is","to","support","outcome","constraints",".","On","the","surface",",","designing","a","wrapper","`","ConstrainedMCAcquisitionFunction","`","could","be","an","elegant","solution","to","this","end",",","but","it","would","still","require","the","acquisition","functions","to","implement","a","`","_sample_forward","`","method","to","weigh","acquisition","utilities","at","the","sample","level",".","Further",",","`","qNoisyExpectedImprovement","`","is","a","special","case","that","is","hard","to","encompass","in","this","pattern",",","since","it","requires","the","computation","of","the","best","*","feasible","*","objective",",","which","requires","access","to","the","constraint","functions",".","However",",","if","the","constraints","are","stored","in","a","wrapper","class",",","they","will","be","inaccessible","to","the","forward","pass",".","These","problems","are","circumvented","by","the","design","of","this","class","."]
docstr: Evaluates the acquisition utility per MC sample based on objective value obj.
  Should utilize the result of `set_X_pending` as needed to account for pending
  function evaluations.
  
  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 acquisition utility values.
docstr_tok: ["Evaluates","the","acquisition","utility","per","MC","sample","based","on","objective","value","obj",".","Should","utilize","the","result","of","`","set_X_pending","`","as","needed","to","account","for","pending","function","evaluations",".","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","acquisition","utility","values","."]
code: def _sample_forward(self, obj: Tensor) -> Tensor:
      """Evaluates the acquisition utility per MC sample based on objective value obj.
      Should utilize the result of `set_X_pending` as needed to account for pending
      function evaluations.
  
      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 acquisition utility values.
      """
      pass
  
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 4 for calling the SampleReducingMCAcquisitionFunction obj's underlying member method code with example usage: obj._sample_forward(obj) without return types