class_docstr: A trace implementation of ELBO-based SVI that supports
  - exhaustive enumeration over discrete sample sites, and
  - local parallel sampling over any sample site in the guide.
  
  To enumerate over a sample site in the ``guide``, mark the site with either
  ``infer={'enumerate': 'sequential'}`` or
  ``infer={'enumerate': 'parallel'}``. To configure all guide sites at once,
  use :func:`~pyro.infer.enum.config_enumerate`. To enumerate over a sample
  site in the ``model``, mark the site ``infer={'enumerate': 'parallel'}``
  and ensure the site does not appear in the ``guide``.
  
  This assumes restricted dependency structure on the model and guide:
  variables outside of an :class:`~pyro.plate` can never depend on
  variables inside that :class:`~pyro.plate`.
class_docstr_tok: ["A","trace","implementation","of","ELBO-based","SVI","that","supports","-","exhaustive","enumeration","over","discrete","sample","sites",",","and","-","local","parallel","sampling","over","any","sample","site","in","the","guide",".","To","enumerate","over","a","sample","site","in","the","``","guide","``",",","mark","the","site","with","either","``","infer=","{","'enumerate","'",":","'sequential","'","}","``","or","``","infer=","{","'enumerate","'",":","'parallel","'","}","``",".","To","configure","all","guide","sites","at","once",",","use",":","func",":","`","~pyro.infer.enum.config_enumerate","`",".","To","enumerate","over","a","sample","site","in","the","``","model","``",",","mark","the","site","``","infer=","{","'enumerate","'",":","'parallel","'","}","``","and","ensure","the","site","does","not","appear","in","the","``","guide","``",".","This","assumes","restricted","dependency","structure","on","the","model","and","guide",":","variables","outside","of","an",":","class",":","`","~pyro.plate","`","can","never","depend","on","variables","inside","that",":","class",":","`","~pyro.plate","`","."]
docstr: Sample from the joint posterior distribution of all model-enumerated sites given all observations
docstr_tok: ["Sample","from","the","joint","posterior","distribution","of","all","model-enumerated","sites","given","all","observations"]
code: def sample_posterior(self, model, guide, *args, **kwargs):
      """
      Sample from the joint posterior distribution of all model-enumerated sites given all observations
      """
      if self.num_particles != 1:
          raise NotImplementedError(
              "TraceEnum_ELBO.sample_posterior() is not "
              "compatible with multiple particles."
          )
      with poutine.block(), warnings.catch_warnings():
          warnings.filterwarnings(
              "ignore", "Found vars in model but not guide"
          )
          model_trace, guide_trace = next(
              self._get_traces(model, guide, args, kwargs)
          )
  
      for name, site in guide_trace.nodes.items():
          if site["type"] == "sample":
              if (
                  "_enumerate_dim" in site["infer"]
                  or "_enum_total" in site["infer"]
              ):
                  raise NotImplementedError(
                      "TraceEnum_ELBO.sample_posterior() is not "
                      "compatible with guide enumeration."
                  )
  
      # TODO replace BackwardSample with torch_sample backend to ubersum
      with BackwardSampleMessenger(model_trace, guide_trace):
          return poutine.replay(model, trace=guide_trace)(
              *args, **kwargs
          )
  
imports: import queue
  import warnings
  import weakref
  from collections import OrderedDict
  import torch
  from opt_einsum import shared_intermediates
  import pyro
  import pyro.distributions
  import pyro.ops.jit
  import pyro.poutine
  from pyro.distributions.util import is_identically_zero
  from pyro.infer.elbo import ELBO
  from pyro.infer.enum import get_importance_trace, iter_discrete_escape, iter_discrete_extend
  from pyro.infer.util import Dice, is_validation_enabled
  from pyro.ops import packed
  from pyro.ops.contract import contract_tensor_tree, contract_to_tensor
  from pyro.ops.rings import SampleRing
  from pyro.poutine.enum_messenger import EnumMessenger
  from pyro.util import check_traceenum_requirements, ignore_jit_warnings, warn_if_nan
label_desc: Use image node_id 7 for calling the TraceEnum_ELBO obj's underlying member method code with example usage: obj.sample_posterior(model, guide) and returns: poutine