class_docstr: The expectation risk measure.
  
  For unconstrained problems, we recommend using the `ExpectationPosteriorTransform`
  instead. `ExpectationPosteriorTransform` directly transforms the posterior
  distribution over `q * n_w` to a posterior of `q` expectations, significantly
  reducing the cost of posterior sampling as a result.
class_docstr_tok: ["The","expectation","risk","measure",".","For","unconstrained","problems",",","we","recommend","using","the","`","ExpectationPosteriorTransform","`","instead",".","`","ExpectationPosteriorTransform","`","directly","transforms","the","posterior","distribution","over","`","q","*","n_w","`","to","a","posterior","of","`","q","`","expectations",",","significantly","reducing","the","cost","of","posterior","sampling","as","a","result","."]
docstr: Calculate the expectation corresponding to the given samples.
  This calculates the expectation / mean / average of each `n_w` samples
  across the q-batch dimension. If `self.weights` is given, the samples
  are scalarized across the output dimension before taking the expectation.
  
  Args:
      samples: A `sample_shape x batch_shape x (q * n_w) x m`-dim tensor of
          posterior samples. The q-batches should be ordered so that each
          `n_w` block of samples correspond to the same input.
      X: A `batch_shape x q x d`-dim tensor of inputs. Ignored.
  
  Returns:
      A `sample_shape x batch_shape x q`-dim tensor of expectation samples.
docstr_tok: ["Calculate","the","expectation","corresponding","to","the","given","samples",".","This","calculates","the","expectation","\/","mean","\/","average","of","each","`","n_w","`","samples","across","the","q-batch","dimension",".","If","`","self.weights","`","is","given",",","the","samples","are","scalarized","across","the","output","dimension","before","taking","the","expectation",".","Args",":","samples",":","A","`","sample_shape","x","batch_shape","x","(","q","*","n_w",")","x","m","`","-dim","tensor","of","posterior","samples",".","The","q-batches","should","be","ordered","so","that","each","`","n_w","`","block","of","samples","correspond","to","the","same","input",".","X",":","A","`","batch_shape","x","q","x","d","`","-dim","tensor","of","inputs",".","Ignored",".","Returns",":","A","`","sample_shape","x","batch_shape","x","q","`","-dim","tensor","of","expectation","samples","."]
code: def forward(
      self, samples: Tensor, X: Optional[Tensor] = None
  ) -> Tensor:
      r"""Calculate the expectation corresponding to the given samples.
      This calculates the expectation / mean / average of each `n_w` samples
      across the q-batch dimension. If `self.weights` is given, the samples
      are scalarized across the output dimension before taking the expectation.
  
      Args:
          samples: A `sample_shape x batch_shape x (q * n_w) x m`-dim tensor of
              posterior samples. The q-batches should be ordered so that each
              `n_w` block of samples correspond to the same input.
          X: A `batch_shape x q x d`-dim tensor of inputs. Ignored.
  
      Returns:
          A `sample_shape x batch_shape x q`-dim tensor of expectation samples.
      """
      prepared_samples = self._prepare_samples(samples)
      return prepared_samples.mean(dim=-1)
  
imports: from abc import ABC, abstractmethod
  from math import ceil
  from typing import Callable, Optional
  import torch
  from botorch.acquisition.multi_objective.objective import IdentityMCMultiOutputObjective
  from botorch.acquisition.objective import IdentityMCObjective, MCAcquisitionObjective
  from torch import Tensor
label_desc: Use image node_id 1 for calling the Expectation obj's underlying member method code with example usage: obj.forward(samples, X) and returns: prepared_samples