class_docstr: Encapsulate Pyro specific logic.
docstr: Convert Pyro data into an InferenceData object.
  
  Parameters
  ----------
  posterior : pyro.infer.MCMC
      Fitted MCMC object from Pyro
  prior: dict
      Prior samples from a Pyro model
  posterior_predictive : dict
      Posterior predictive samples for the posterior
  predictions: dict
      Out of sample predictions
  constant_data: dict
      Dictionary containing constant data variables mapped to their values.
  predictions_constant_data: dict
      Constant data used for out-of-sample predictions.
  coords : dict[str] -> list[str]
      Map of dimensions to coordinates
  dims : dict[str] -> list[str]
      Map variable names to their coordinates
  pred_dims: dict
      Dims for predictions data. Map variable names to their coordinates.
  num_chains: int
      Number of chains used for sampling. Ignored if posterior is present.
docstr_tok: ["Convert","Pyro","data","into","an","InferenceData","object",".","Parameters","--","--","--","--","--","posterior",":","pyro.infer.MCMC","Fitted","MCMC","object","from","Pyro","prior",":","dict","Prior","samples","from","a","Pyro","model","posterior_predictive",":","dict","Posterior","predictive","samples","for","the","posterior","predictions",":","dict","Out","of","sample","predictions","constant_data",":","dict","Dictionary","containing","constant","data","variables","mapped","to","their","values",".","predictions_constant_data",":","dict","Constant","data","used","for","out-of-sample","predictions",".","coords",":","dict","[","str","]","-",">","list","[","str","]","Map","of","dimensions","to","coordinates","dims",":","dict","[","str","]","-",">","list","[","str","]","Map","variable","names","to","their","coordinates","pred_dims",":","dict","Dims","for","predictions","data",".","Map","variable","names","to","their","coordinates",".","num_chains",":","int","Number","of","chains","used","for","sampling",".","Ignored","if","posterior","is","present","."]
code: def __init__(
      self,
      *,
      posterior=None,
      prior=None,
      posterior_predictive=None,
      log_likelihood=None,
      predictions=None,
      constant_data=None,
      predictions_constant_data=None,
      coords=None,
      dims=None,
      pred_dims=None,
      num_chains=1,
  ):
      """Convert Pyro data into an InferenceData object.
  
      Parameters
      ----------
      posterior : pyro.infer.MCMC
          Fitted MCMC object from Pyro
      prior: dict
          Prior samples from a Pyro model
      posterior_predictive : dict
          Posterior predictive samples for the posterior
      predictions: dict
          Out of sample predictions
      constant_data: dict
          Dictionary containing constant data variables mapped to their values.
      predictions_constant_data: dict
          Constant data used for out-of-sample predictions.
      coords : dict[str] -> list[str]
          Map of dimensions to coordinates
      dims : dict[str] -> list[str]
          Map variable names to their coordinates
      pred_dims: dict
          Dims for predictions data. Map variable names to their coordinates.
      num_chains: int
          Number of chains used for sampling. Ignored if posterior is present.
      """
      self.posterior = posterior
      self.prior = prior
      self.posterior_predictive = posterior_predictive
      self.log_likelihood = (
          rcParams["data.log_likelihood"]
          if log_likelihood is None
          else log_likelihood
      )
      self.predictions = predictions
      self.constant_data = constant_data
      self.predictions_constant_data = predictions_constant_data
      self.coords = coords
      self.dims = {} if dims is None else dims
      self.pred_dims = {} if pred_dims is None else pred_dims
      import pyro
  
      def arbitrary_element(dct):
          return next(iter(dct.values()))
  
      self.pyro = pyro
      if posterior is not None:
          self.nchains, self.ndraws = (
              posterior.num_chains,
              posterior.num_samples,
          )
          if version.parse(pyro.__version__) >= version.parse("1.0.0"):
              self.model = self.posterior.kernel.model
              # model arguments and keyword arguments
              self._args = (
                  self.posterior._args
              )  # pylint: disable=protected-access
              self._kwargs = (
                  self.posterior._kwargs
              )  # pylint: disable=protected-access
      else:
          self.nchains = num_chains
          get_from = None
          if predictions is not None:
              get_from = predictions
          elif posterior_predictive is not None:
              get_from = posterior_predictive
          elif prior is not None:
              get_from = prior
          if (
              get_from is None
              and constant_data is None
              and predictions_constant_data is None
          ):
              raise ValueError(
                  "When constructing InferenceData must have at least"
                  " one of posterior, prior, posterior_predictive or predictions."
              )
          if get_from is not None:
              aelem = arbitrary_element(get_from)
              self.ndraws = aelem.shape[0] // self.nchains
  
      observations = {}
      if self.model is not None:
          trace = pyro.poutine.trace(
              self.model
          ).get_trace(  # pylint: disable=not-callable
              *self._args, **self._kwargs
          )
          observations = {
              name: site["value"].cpu()
              for name, site in trace.nodes.items()
              if site["type"] == "sample" and site["is_observed"]
          }
      self.observations = observations if observations else None
  
imports: import logging
  from typing import Callable, Optional
  import warnings
  import numpy
  from packaging import version
  from ..None import utils
  from ..rcparams import rcParams
  from .base import dict_to_dataset, requires
  from .inference_data import InferenceData
label_desc: Use image node_id 1 to create a new PyroConverter object  with example: obj = PyroConverter()