class_docstr: Transform the `batch x (q * n_w) x m` posterior into a `batch x q x m`
  posterior of the expectation. The expectation is calculated over each
  consecutive `n_w` block of points in the posterior.
  
  This is intended for use with `InputPerturbation` or `AppendFeatures` for
  optimizing the expectation over `n_w` points. This should not be used when
  there are constraints present, since this does not take into account
  the feasibility of the objectives.
  
  Note: This is different than `ScalarizedPosteriorTransform` in that
  this operates over the q-batch dimension.
class_docstr_tok: ["Transform","the","`","batch","x","(","q","*","n_w",")","x","m","`","posterior","into","a","`","batch","x","q","x","m","`","posterior","of","the","expectation",".","The","expectation","is","calculated","over","each","consecutive","`","n_w","`","block","of","points","in","the","posterior",".","This","is","intended","for","use","with","`","InputPerturbation","`","or","`","AppendFeatures","`","for","optimizing","the","expectation","over","`","n_w","`","points",".","This","should","not","be","used","when","there","are","constraints","present",",","since","this","does","not","take","into","account","the","feasibility","of","the","objectives",".","Note",":","This","is","different","than","`","ScalarizedPosteriorTransform","`","in","that","this","operates","over","the","q-batch","dimension","."]
docstr: A posterior transform calculating the expectation over the q-batch
  dimension.
  
  Args:
      n_w: The number of points in the q-batch of the posterior to compute
          the expectation over. This corresponds to the size of the
          `feature_set` of `AppendFeatures` or the size of the `perturbation_set`
          of `InputPerturbation`.
      weights: An optional `n_w x m`-dim tensor of weights. Can be used to
          compute a weighted expectation. Weights are normalized before use.
code: def __init__(
      self, n_w: int, weights: Optional[Tensor] = None
  ) -> None:
      r"""A posterior transform calculating the expectation over the q-batch
      dimension.
  
      Args:
          n_w: The number of points in the q-batch of the posterior to compute
              the expectation over. This corresponds to the size of the
              `feature_set` of `AppendFeatures` or the size of the `perturbation_set`
              of `InputPerturbation`.
          weights: An optional `n_w x m`-dim tensor of weights. Can be used to
              compute a weighted expectation. Weights are normalized before use.
      """
      super().__init__()
      if weights is not None:
          if weights.dim() != 2 or weights.shape[0] != n_w:
              raise ValueError(
                  "`weights` must be a tensor of size `n_w x m`."
              )
          if torch.any(weights < 0):
              raise ValueError("`weights` must be non-negative.")
      else:
          weights = torch.ones(n_w, 1)
      # Normalize the weights.
      weights = weights / weights.sum(dim=0)
      self.register_buffer("weights", weights)
      self.n_w = n_w
  
imports: from __future__ import annotations
  import inspect
  import warnings
  from abc import ABC, abstractmethod
  from typing import Callable, List, Optional, TYPE_CHECKING, Union
  import torch
  from botorch.exceptions.errors import BotorchTensorDimensionError, UnsupportedError
  from botorch.exceptions.warnings import InputDataWarning
  from botorch.models.model import Model
  from botorch.models.transforms.outcome import Standardize
  from botorch.posteriors.gpytorch import GPyTorchPosterior, scalarize_posterior
  from botorch.sampling import IIDNormalSampler
  from botorch.utils import apply_constraints
  from gpytorch.distributions import MultitaskMultivariateNormal, MultivariateNormal
  from linear_operator.operators.dense_linear_operator import to_linear_operator
  from torch import Tensor
  from torch.nn import Module
  from botorch.models.deterministic import DeterministicModel
label_desc: Use image node_id 1 to create a new ExpectationPosteriorTransform object from inherited base classes: PosteriorTransform with example: obj = ExpectationPosteriorTransform(n_w, weights)