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)
class_docstr_tok: ["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",")"]
docstr: Generate latent samples while reusing work from SVI.step().
docstr_tok: ["Generate","latent","samples","while","reusing","work","from","SVI.step","(",")","."]
code: def sample_saved(self):
      """
      Generate latent samples while reusing work from SVI.step().
      """
      model, model_trace, guide_trace, args, kwargs = self._saved_state
      model = poutine.replay(model, guide_trace)
      temperature = 1
      return _sample_posterior_from_trace(
          model,
          model_trace,
          temperature,
          self.strict_enumeration_warning,
          *args,
          **kwargs,
      )
  
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 2 for calling the TraceEnumSample_ELBO obj's underlying member method code with example usage: obj.sample_saved() and returns: _sample_posterior_from_trace