class_docstr: A TraceGraph implementation of ELBO-based SVI. The gradient estimator
  is constructed along the lines of reference [1] specialized to the case
  of the ELBO. It supports arbitrary dependency structure for the model
  and guide as well as baselines for non-reparameterizable random variables.
  Fine-grained conditional dependency information as recorded in the
  :class:`~pyro.poutine.trace.Trace` is used to reduce the variance of the gradient estimator.
  In particular provenance tracking [3] is used to find the ``cost`` terms
  that depend on each non-reparameterizable sample site.
  
  References
  
  [1] `Gradient Estimation Using Stochastic Computation Graphs`,
      John Schulman, Nicolas Heess, Theophane Weber, Pieter Abbeel
  
  [2] `Neural Variational Inference and Learning in Belief Networks`
      Andriy Mnih, Karol Gregor
  
  [3] `Nonstandard Interpretations of Probabilistic Programs for Efficient Inference`,
      David Wingate, Noah Goodman, Andreas Stuhlmüller, Jeffrey Siskind
code: def _loss_and_surrogate_loss(self, model, guide, args, kwargs):
      loss = 0.0
      surrogate_loss = 0.0
  
      for model_trace, guide_trace in self._get_traces(
          model, guide, args, kwargs
      ):
          lp, slp = self._loss_and_surrogate_loss_particle(
              model_trace, guide_trace
          )
          loss += lp
          surrogate_loss += slp
  
      loss /= self.num_particles
      surrogate_loss /= self.num_particles
  
      return loss, surrogate_loss
  
imports: import weakref
  from collections import defaultdict
  from operator import itemgetter
  import torch
  import pyro
  import pyro.ops.jit
  from pyro.distributions.util import detach, is_identically_zero
  from pyro.infer import ELBO
  from pyro.infer.enum import get_importance_trace
  from pyro.infer.util import MultiFrameTensor, get_plate_stacks, is_validation_enabled, torch_backward, torch_item
  from pyro.ops.provenance import detach_provenance, get_provenance, track_provenance
  from pyro.poutine.messenger import Messenger
  from pyro.poutine.subsample_messenger import _Subsample
  from pyro.util import check_if_enumerated, warn_if_nan
label_desc: Use image node_id 4 for calling the TraceGraph_ELBO obj's underlying member method code with example usage: obj._loss_and_surrogate_loss(model, guide, args, kwargs) and returns: loss,  surrogate_loss