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: Returns a single trace from the guide, and the model that is run
  against it.
docstr_tok: ["Returns","a","single","trace","from","the","guide",",","and","the","model","that","is","run","against","it","."]
code: def _get_trace(self, model, guide, args, kwargs):
      """
      Returns a single trace from the guide, and the model that is run
      against it.
      """
      model_trace, guide_trace = get_importance_trace(
          "flat", self.max_plate_nesting, model, guide, args, kwargs
      )
  
      if is_validation_enabled():
          check_traceenum_requirements(model_trace, guide_trace)
          _check_tmc_elbo_constraint(model_trace, guide_trace)
  
          has_enumerated_sites = any(
              site["infer"].get("enumerate")
              for trace in (guide_trace, model_trace)
              for name, site in trace.nodes.items()
              if site["type"] == "sample"
          )
  
          if (
              self.strict_enumeration_warning
              and not has_enumerated_sites
          ):
              warnings.warn(
                  "TraceEnum_ELBO found no sample sites configured for enumeration. "
                  "If you want to enumerate sites, you need to @config_enumerate or set "
                  'infer={"enumerate": "sequential"} or infer={"enumerate": "parallel"}? '
                  "If you do not want to enumerate, consider using Trace_ELBO instead."
              )
  
      guide_trace.pack_tensors()
      model_trace.pack_tensors(guide_trace.plate_to_symbol)
      return model_trace, guide_trace
  
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 1 for calling the TraceEnum_ELBO obj's underlying member method code with example usage: obj._get_trace(model, guide, args, kwargs) and returns: model_trace,  guide_trace