class_docstr: Base class for all Gaussian Process estimators.
  
  Most notably, a GPyTorch compatible criterion and likelihood should be
  provided.
class_docstr_tok: ["Base","class","for","all","Gaussian","Process","estimators",".","Most","notably",",","a","GPyTorch","compatible","criterion","and","likelihood","should","be","provided","."]
docstr: Return samples conditioned on input data.
  
  The GP doesn't need to be fitted but it must be initialized.
  
  By default, samples all calculated including gradients. If you don't
  need the gradients, call ``sample`` inside ``torch.no_grad()``.
  
  If the probability distribution does not support the ``rsample`` method
  (i.e. sampling with gradients), try ``sample`` (i.e. without gradients)
  instead. One such distribution, at the time of writing, is Bernoulli.
  
  X : input data
    The samples where the GP is evaluated.
  
  n_samples : int
    The number of samples to return
  
  axis : int (default=-1)
    The concatenation axis of the samples. Since samples can come in
    batches, they must be concatenated.
  
  Returns
  -------
  samples : torch.Tensor
    Samples from the posterior distribution.
docstr_tok: ["Return","samples","conditioned","on","input","data",".","The","GP","does","n't","need","to","be","fitted","but","it","must","be","initialized",".","By","default",",","samples","all","calculated","including","gradients",".","If","you","don't","need","the","gradients",",","call","``","sample","``","inside","``","torch.no_grad","(",")","``",".","If","the","probability","distribution","does","not","support","the","``","rsample","``","method","(","i.e",".","sampling","with","gradients",")",",","try","``","sample","``","(","i.e",".","without","gradients",")","instead",".","One","such","distribution",",","at","the","time","of","writing",",","is","Bernoulli",".","X",":","input","data","The","samples","where","the","GP","is","evaluated",".","n_samples",":","int","The","number","of","samples","to","return","axis",":","int","(","default=-1",")","The","concatenation","axis","of","the","samples",".","Since","samples","can","come","in","batches",",","they","must","be","concatenated",".","Returns","--","--","--","-","samples",":","torch.Tensor","Samples","from","the","posterior","distribution","."]
code: def sample(self, X, n_samples, axis=-1):
      """Return samples conditioned on input data.
  
      The GP doesn't need to be fitted but it must be initialized.
  
      By default, samples all calculated including gradients. If you don't
      need the gradients, call ``sample`` inside ``torch.no_grad()``.
  
      If the probability distribution does not support the ``rsample`` method
      (i.e. sampling with gradients), try ``sample`` (i.e. without gradients)
      instead. One such distribution, at the time of writing, is Bernoulli.
  
      X : input data
        The samples where the GP is evaluated.
  
      n_samples : int
        The number of samples to return
  
      axis : int (default=-1)
        The concatenation axis of the samples. Since samples can come in
        batches, they must be concatenated.
  
      Returns
      -------
      samples : torch.Tensor
        Samples from the posterior distribution.
  
      """
      self.check_is_fitted()
      samples = []
      for p in self.forward_iter(X):
          try:
              sample = p.rsample(torch.Size([n_samples]))
          except NotImplementedError:
              # some distributions like Bernoulli have not implemented rsample
              # (sampling with gradients), try sample instead.
              sample = p.sample(torch.Size([n_samples]))
          samples.append(sample)
  
      return torch.cat(samples, axis=axis)
  
imports: import pickle
  import re
  import gpytorch
  import numpy
  import torch
  from skorch.net import NeuralNet
  from skorch.dataset import ValidSplit
  from skorch.dataset import unpack_data
  from skorch.callbacks import EpochScoring
  from skorch.callbacks import EpochTimer
  from skorch.callbacks import PassthroughScoring
  from skorch.callbacks import PrintLog
  from skorch.utils import check_is_fitted
  from skorch.utils import get_dim
  from skorch.utils import is_dataset
  from skorch.utils import to_numpy
  from skorch.utils import to_tensor
label_desc: Use image node_id 11 for calling the GPBase obj's underlying member method code with example usage: obj.sample(X, n_samples, axis) and returns: torch