class_docstr: EXPERIMENTAL class used to construct predictive distribution. The predictive
  distribution is obtained by running the `model` conditioned on latent samples
  from `posterior_samples`. If a `guide` is provided, then posterior samples
  from all the latent sites are also returned.
  
  .. warning::
      The interface for the :class:`Predictive` class is experimental, and
      might change in the future.
  
  :param model: Python callable containing Pyro primitives.
  :param dict posterior_samples: dictionary of samples from the posterior.
  :param callable guide: optional guide to get posterior samples of sites not present
      in `posterior_samples`.
  :param int num_samples: number of samples to draw from the predictive distribution.
      This argument has no effect if ``posterior_samples`` is non-empty, in which case,
      the leading dimension size of samples in ``posterior_samples`` is used.
  :param return_sites: sites to return; by default only sample sites not present
      in `posterior_samples` are returned.
  :type return_sites: list, tuple, or set
  :param bool parallel: predict in parallel by wrapping the existing model
      in an outermost `plate` messenger. Note that this requires that the model has
      all batch dims correctly annotated via :class:`~pyro.plate`. Default is `False`.
docstr: Returns dict of samples from the predictive distribution. By default, only sample sites not
  contained in `posterior_samples` are returned. This can be modified by changing the
  `return_sites` keyword argument of this :class:`Predictive` instance.
  
  .. note:: This method is used internally by :class:`~torch.nn.Module`.
      Users should instead use :meth:`~torch.nn.Module.__call__` as in
      ``Predictive(model)(*args, **kwargs)``.
  
  :param args: model arguments.
  :param kwargs: model keyword arguments.
docstr_tok: ["Returns","dict","of","samples","from","the","predictive","distribution",".","By","default",",","only","sample","sites","not","contained","in","`","posterior_samples","`","are","returned",".","This","can","be","modified","by","changing","the","`","return_sites","`","keyword","argument","of","this",":","class",":","`","Predictive","`","instance",".","..","note",":",":","This","method","is","used","internally","by",":","class",":","`","~torch.nn.Module","`",".","Users","should","instead","use",":","meth",":","`","~torch.nn.Module.__call__","`","as","in","``","Predictive","(","model",")","(","*","args",",","*","*","kwargs",")","``",".",":","param","args",":","model","arguments",".",":","param","kwargs",":","model","keyword","arguments","."]
code: def forward(self, *args, **kwargs):
      """
      Returns dict of samples from the predictive distribution. By default, only sample sites not
      contained in `posterior_samples` are returned. This can be modified by changing the
      `return_sites` keyword argument of this :class:`Predictive` instance.
  
      .. note:: This method is used internally by :class:`~torch.nn.Module`.
          Users should instead use :meth:`~torch.nn.Module.__call__` as in
          ``Predictive(model)(*args, **kwargs)``.
  
      :param args: model arguments.
      :param kwargs: model keyword arguments.
      """
      posterior_samples = self.posterior_samples
      return_sites = self.return_sites
      if self.guide is not None:
          # return all sites by default if a guide is provided.
          return_sites = None if not return_sites else return_sites
          posterior_samples = _predictive(
              self.guide,
              posterior_samples,
              self.num_samples,
              return_sites=None,
              parallel=self.parallel,
              model_args=args,
              model_kwargs=kwargs,
          )
      return _predictive(
          self.model,
          posterior_samples,
          self.num_samples,
          return_sites=return_sites,
          parallel=self.parallel,
          model_args=args,
          model_kwargs=kwargs,
      )
  
file_path: pyro/pyro/infer/predictive.py
imports: import warnings
  from functools import reduce
  import torch
  import pyro
  import pyro.poutine
  from pyro.poutine.util import prune_subsample_sites
label_desc: Use image node_id 3 for calling the Predictive obj's underlying member method code with example usage: obj.forward() and returns: _predictive