class_docstr: A trace-based implementation of Tensor Monte Carlo [1]
  by way of Tensor Variable Elimination [2] that supports:
  - local parallel sampling over any sample site in the model or guide
  - exhaustive enumeration over any sample site in the model or guide
  
  To take multiple samples, mark the site with
  ``infer={'enumerate': 'parallel', 'num_samples': N}``.
  To configure all sites in a model or guide at once,
  use :func:`~pyro.infer.enum.config_enumerate` .
  To enumerate or sample a sample site in the ``model``,
  mark the site 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` .
  
  References
  
  [1] `Tensor Monte Carlo: Particle Methods for the GPU Era`,
      Laurence Aitchison (2018)
  
  [2] `Tensor Variable Elimination for Plated Factor Graphs`,
      Fritz Obermeyer, Eli Bingham, Martin Jankowiak, Justin Chiu, Neeraj Pradhan,
      Alexander Rush, Noah Goodman (2019)
docstr: :returns: a differentiable estimate of the marginal log-likelihood
  :rtype: torch.Tensor
  :raises ValueError: if the ELBO is not differentiable (e.g. is
      identically zero)
  
  Computes a differentiable TMC estimate using ``num_particles`` many samples
  (particles).  The result should be infinitely differentiable (as long
  as underlying derivatives have been implemented).
docstr_tok: [":","returns",":","a","differentiable","estimate","of","the","marginal","log-likelihood",":","rtype",":","torch.Tensor",":","raises","ValueError",":","if","the","ELBO","is","not","differentiable","(","e.g",".","is","identically","zero",")","Computes","a","differentiable","TMC","estimate","using","``","num_particles","``","many","samples","(","particles",")",".","The","result","should","be","infinitely","differentiable","(","as","long","as","underlying","derivatives","have","been","implemented",")","."]
code: def differentiable_loss(self, model, guide, *args, **kwargs):
      """
      :returns: a differentiable estimate of the marginal log-likelihood
      :rtype: torch.Tensor
      :raises ValueError: if the ELBO is not differentiable (e.g. is
          identically zero)
  
      Computes a differentiable TMC estimate using ``num_particles`` many samples
      (particles).  The result should be infinitely differentiable (as long
      as underlying derivatives have been implemented).
      """
      elbo = 0.0
      for model_trace, guide_trace in self._get_traces(
          model, guide, args, kwargs
      ):
          elbo_particle = _compute_tmc_estimate(
              model_trace, guide_trace
          )
          if is_identically_zero(elbo_particle):
              continue
  
          elbo = elbo + elbo_particle
      elbo = elbo / self.num_particles
  
      loss = -elbo
      warn_if_nan(loss, "loss")
      return loss
  
imports: import queue
  import warnings
  import torch
  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 compute_site_dice_factor, is_validation_enabled, torch_item
  from pyro.ops import packed
  from pyro.ops.contract import einsum
  from pyro.poutine.enum_messenger import EnumMessenger
  from pyro.util import check_traceenum_requirements, warn_if_nan
label_desc: Use image node_id 3 for calling the TraceTMC_ELBO obj's underlying member method code with example usage: obj.differentiable_loss(model, guide) and returns: loss