class_docstr: A posterior based on GPyTorch's multi-variate Normal distributions.
docstr: Sample from the posterior (with gradients) using base samples.
  
  This is intended to be used with a sampler that produces the corresponding base
  samples, and enables acquisition optimization via Sample Average Approximation.
  
  Args:
      sample_shape: A `torch.Size` object specifying the sample shape. To
          draw `n` samples, set to `torch.Size([n])`. To draw `b` batches
          of `n` samples each, set to `torch.Size([b, n])`.
      base_samples: A Tensor of `N(0, I)` base samples of shape
          `sample_shape x base_sample_shape`, typically obtained from
          a `Sampler`. This is used for deterministic optimization.
  
  Returns:
      Samples from the posterior, a tensor of shape
      `self._extended_shape(sample_shape=sample_shape)`.
docstr_tok: ["Sample","from","the","posterior","(","with","gradients",")","using","base","samples",".","This","is","intended","to","be","used","with","a","sampler","that","produces","the","corresponding","base","samples",",","and","enables","acquisition","optimization","via","Sample","Average","Approximation",".","Args",":","sample_shape",":","A","`","torch.Size","`","object","specifying","the","sample","shape",".","To","draw","`","n","`","samples",",","set","to","`","torch.Size","(","[","n","]",")","`",".","To","draw","`","b","`","batches","of","`","n","`","samples","each",",","set","to","`","torch.Size","(","[","b",",","n","]",")","`",".","base_samples",":","A","Tensor","of","`","N","(","0",",","I",")","`","base","samples","of","shape","`","sample_shape","x","base_sample_shape","`",",","typically","obtained","from","a","`","Sampler","`",".","This","is","used","for","deterministic","optimization",".","Returns",":","Samples","from","the","posterior",",","a","tensor","of","shape","`","self._extended_shape","(","sample_shape=sample_shape",")","`","."]
code: def rsample_from_base_samples(
      self,
      sample_shape: torch.Size,
      base_samples: Tensor,
  ) -> Tensor:
      r"""Sample from the posterior (with gradients) using base samples.
  
      This is intended to be used with a sampler that produces the corresponding base
      samples, and enables acquisition optimization via Sample Average Approximation.
  
      Args:
          sample_shape: A `torch.Size` object specifying the sample shape. To
              draw `n` samples, set to `torch.Size([n])`. To draw `b` batches
              of `n` samples each, set to `torch.Size([b, n])`.
          base_samples: A Tensor of `N(0, I)` base samples of shape
              `sample_shape x base_sample_shape`, typically obtained from
              a `Sampler`. This is used for deterministic optimization.
  
      Returns:
          Samples from the posterior, a tensor of shape
          `self._extended_shape(sample_shape=sample_shape)`.
      """
      if base_samples.shape[: len(sample_shape)] != sample_shape:
          raise RuntimeError(
              "`sample_shape` disagrees with shape of `base_samples`. "
              f"Got {sample_shape=} and {base_samples.shape=}."
          )
      if self._is_mt:
          base_samples = _reshape_base_samples_non_interleaved(
              mvn=self.distribution,
              base_samples=base_samples,
              sample_shape=sample_shape,
          )
      with ExitStack() as es:
          if linop_settings._fast_covar_root_decomposition.is_default():
              es.enter_context(
                  linop_settings._fast_covar_root_decomposition(False)
              )
          samples = self.distribution.rsample(
              sample_shape=sample_shape, base_samples=base_samples
          )
      if not self._is_mt:
          samples = samples.unsqueeze(-1)
      return samples
  
imports: from __future__ import annotations
  import warnings
  from contextlib import ExitStack
  from typing import Optional, Tuple, TYPE_CHECKING, Union
  import torch
  from botorch.exceptions.errors import BotorchTensorDimensionError
  from botorch.posteriors.base_samples import _reshape_base_samples_non_interleaved
  from botorch.posteriors.torch import TorchPosterior
  from gpytorch.distributions import MultitaskMultivariateNormal, MultivariateNormal
  from linear_operator import settings
  from linear_operator.operators import BlockDiagLinearOperator, DenseLinearOperator, LinearOperator, SumLinearOperator
  from torch import Tensor
  from torch.distributions import Normal
label_desc: Use image node_id 6 for calling the GPyTorchPosterior obj's underlying member method code with example usage: obj.rsample_from_base_samples(sample_shape, base_samples) and returns: samples