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: Runs the guide and runs the model against the guide with
  the result packaged as a trace generator.
docstr_tok: ["Runs","the","guide","and","runs","the","model","against","the","guide","with","the","result","packaged","as","a","trace","generator","."]
code: def _get_traces(self, model, guide, args, kwargs):
      """
      Runs the guide and runs the model against the guide with
      the result packaged as a trace generator.
      """
      if isinstance(poutine.unwrap(guide), poutine.messenger.Messenger):
          raise NotImplementedError(
              "TraceEnum_ELBO does not support GuideMessenger"
          )
      if self.max_plate_nesting == float("inf"):
          self._guess_max_plate_nesting(model, guide, args, kwargs)
      if self.vectorize_particles:
          guide = self._vectorized_num_particles(guide)
          model = self._vectorized_num_particles(model)
  
      # Enable parallel enumeration over the vectorized guide and model.
      # The model allocates enumeration dimensions after (to the left of) the guide,
      # accomplished by preserving the _ENUM_ALLOCATOR state after the guide call.
      guide_enum = EnumMessenger(
          first_available_dim=-1 - self.max_plate_nesting
      )
      model_enum = EnumMessenger()  # preserve _ENUM_ALLOCATOR state
      guide = guide_enum(guide)
      model = model_enum(model)
  
      q = queue.LifoQueue()
      guide = poutine.queue(
          guide,
          q,
          escape_fn=iter_discrete_escape,
          extend_fn=iter_discrete_extend,
      )
      for i in range(
          1 if self.vectorize_particles else self.num_particles
      ):
          q.put(poutine.Trace())
          while not q.empty():
              yield self._get_trace(model, guide, 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 2 for calling the TraceEnum_ELBO obj's underlying member method code with example usage: obj._get_traces(model, guide, args, kwargs) without return types