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: Abstract base class for samplers.
  
  Args:
      sample_shape: The `sample_shape` of the samples to generate. The full shape
          of the samples is given by `posterior._extended_shape(sample_shape)`.
      seed: An optional seed to use for sampling.
      **kwargs: Catch-all for deprecated kwargs.
docstr_tok: ["Abstract","base","class","for","samplers",".","Args",":","sample_shape",":","The","`","sample_shape","`","of","the","samples","to","generate",".","The","full","shape","of","the","samples","is","given","by","`","posterior._extended_shape","(","sample_shape",")","`",".","seed",":","An","optional","seed","to","use","for","sampling",".","*","*","kwargs",":","Catch-all","for","deprecated","kwargs","."]
code: def __init__(
      self,
      sample_shape: torch.Size,
      seed: Optional[int] = None,
      **kwargs: Any,
  ) -> None:
      r"""Abstract base class for samplers.
  
      Args:
          sample_shape: The `sample_shape` of the samples to generate. The full shape
              of the samples is given by `posterior._extended_shape(sample_shape)`.
          seed: An optional seed to use for sampling.
          **kwargs: Catch-all for deprecated kwargs.
      """
      super().__init__()
      if not isinstance(sample_shape, torch.Size):
          if isinstance(sample_shape, int):
              sample_shape = torch.Size([sample_shape])
              warnings.warn(
                  "The first positional argument of samplers, `num_samples`, has "
                  "been deprecated and replaced with `sample_shape`, which expects "
                  "a `torch.Size` object.",
                  DeprecationWarning,
              )
          else:
              raise InputDataError(
                  "Expected `sample_shape` to be a `torch.Size` object, "
                  f"got {sample_shape}."
              )
      for k, v in kwargs.items():
          if k == "resample":
              if v is True:
                  raise RuntimeError(
                      KWARG_ERR_MSG.format(k, "StochasticSampler")
                  )
              else:
                  warnings.warn(
                      KWARGS_DEPRECATED_MSG.format(k),
                      DeprecationWarning,
                  )
          elif k == "collapse_batch_dims":
              if v is False:
                  raise RuntimeError(
                      KWARG_ERR_MSG.format(k, "ForkedRNGSampler")
                  )
              else:
                  warnings.warn(
                      KWARGS_DEPRECATED_MSG.format(k),
                      DeprecationWarning,
                  )
          else:
              raise RuntimeError(
                  f"Recevied an unknown argument {k}: {v}."
              )
  
      self.sample_shape = sample_shape
      self.seed = (
          seed
          if seed is not None
          else torch.randint(0, 1000000, (1,)).item()
      )
      self.register_buffer("base_samples", None)
  
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 1 to create a new MCSampler object from inherited base classes: Module, ABC with example: obj = MCSampler(sample_shape, seed)