class_docstr: Abstract base class for Samplers.
  
  Subclasses must implement the `forward` method.
  
  Example:
      This method is usually not called directly, but via the sampler's
      `__call__` method:
      >>> posterior = model.posterior(test_X)
      >>> samples = sampler(posterior)
  
  :meta private:
class_docstr_tok: ["Abstract","base","class","for","Samplers",".","Subclasses","must","implement","the","`","forward","`","method",".","Example",":","This","method","is","usually","not","called","directly",",","but","via","the","sampler's","`","__call__","`","method",":",">",">",">","posterior","=","model.posterior","(","test_X",")",">",">",">","samples","=","sampler","(","posterior",")",":","meta","private",":"]
docstr: Get the shape of the base samples with the t-batches collapsed.
  
  Args:
      posterior: The posterior to sample from.
  
  Returns:
      The collapsed shape of the base samples expected by the posterior. The
      t-batch dimensions of the base samples are collapsed to size 1. This is
      useful to prevent sampling variance across t-batches.
docstr_tok: ["Get","the","shape","of","the","base","samples","with","the","t-batches","collapsed",".","Args",":","posterior",":","The","posterior","to","sample","from",".","Returns",":","The","collapsed","shape","of","the","base","samples","expected","by","the","posterior",".","The","t-batch","dimensions","of","the","base","samples","are","collapsed","to","size","1",".","This","is","useful","to","prevent","sampling","variance","across","t-batches","."]
code: def _get_collapsed_shape(self, posterior: Posterior) -> torch.Size:
      r"""Get the shape of the base samples with the t-batches collapsed.
  
      Args:
          posterior: The posterior to sample from.
  
      Returns:
          The collapsed shape of the base samples expected by the posterior. The
          t-batch dimensions of the base samples are collapsed to size 1. This is
          useful to prevent sampling variance across t-batches.
      """
      base_sample_shape = posterior.base_sample_shape
      batch_start, batch_end = self._get_batch_range(posterior)
      base_sample_shape = (
          base_sample_shape[:batch_start]
          + torch.Size(
              [1 for _ in base_sample_shape[batch_start:batch_end]]
          )
          + base_sample_shape[batch_end:]
      )
      return self.sample_shape + base_sample_shape
  
file_path: botorch/botorch/sampling/base.py
imports: from __future__ import annotations
  import warnings
  from abc import ABC, abstractmethod
  from typing import Any, Optional, Tuple
  import torch
  from botorch.exceptions.errors import InputDataError
  from botorch.posteriors import Posterior
  from torch import Tensor
  from torch.nn import Module
label_desc: Use image node_id 4 for calling the MCSampler obj's underlying member method code with example usage: obj._get_collapsed_shape(posterior) and returns: unknown