class_docstr: This extends :class:`TraceEnum_ELBO` to make it cheaper to sample from
  discrete latent states during SVI.
  
  The following are equivalent but the first is cheaper, sharing work
  between the computations of ``loss`` and ``z``::
  
      # Version 1.
      elbo = TraceEnumSample_ELBO(max_plate_nesting=1)
      loss = elbo.loss(*args, **kwargs)
      z = elbo.sample_saved()
  
      # Version 2.
      elbo = TraceEnum_ELBO(max_plate_nesting=1)
      loss = elbo.loss(*args, **kwargs)
      guide_trace = poutine.trace(guide).get_trace(*args, **kwargs)
      z = infer_discrete(poutine.replay(model, guide_trace),
                         first_available_dim=-2)(*args, **kwargs)
code: def _get_trace(self, model, guide, args, kwargs):
      model_trace, guide_trace = super()._get_trace(
          model, guide, args, kwargs
      )
  
      # Mark all sample sites with require_backward to gather enumerated
      # sites and adjust cond_indep_stack of all sample sites.
      for node in model_trace.nodes.values():
          if node["type"] == "sample" and not node["is_observed"]:
              log_prob = node["packed"]["unscaled_log_prob"]
              require_backward(log_prob)
  
      self._saved_state = model, model_trace, guide_trace, args, kwargs
      return model_trace, guide_trace
  
imports: import functools
  import warnings
  from collections import OrderedDict
  from opt_einsum import shared_intermediates
  import pyro.ops.packed
  from pyro import poutine
  from pyro.infer.traceenum_elbo import TraceEnum_ELBO
  from pyro.ops.contract import contract_tensor_tree
  from pyro.ops.einsum.adjoint import require_backward
  from pyro.ops.rings import MapRing, SampleRing
  from pyro.poutine.enum_messenger import EnumMessenger
  from pyro.poutine.replay_messenger import ReplayMessenger
  from pyro.poutine.util import prune_subsample_sites
  from pyro.util import jit_iter
label_desc: Use image node_id 1 for calling the TraceEnumSample_ELBO obj's underlying member method code with example usage: obj._get_trace(model, guide, args, kwargs) and returns: model_trace,  guide_trace