class_docstr: Like :class:`TraceGraph_ELBO` but uses :func:`torch.jit.trace` to
  compile :meth:`loss_and_grads`.
  
  This works only for a limited set of models:
  
  -   Models must have static structure.
  -   Models must not depend on any global data (except the param store).
  -   All model inputs that are tensors must be passed in via ``*args``.
  -   All model inputs that are *not* tensors must be passed in via
      ``**kwargs``, and compilation will be triggered once per unique
      ``**kwargs``.
code: def loss_and_grads(self, model, guide, *args, **kwargs):
      kwargs["_pyro_model_id"] = id(model)
      kwargs["_pyro_guide_id"] = id(guide)
      if getattr(self, "_jit_loss_and_surrogate_loss", None) is None:
          # build a closure for loss_and_surrogate_loss
          weakself = weakref.ref(self)
  
          @pyro.ops.jit.trace(
              ignore_warnings=self.ignore_jit_warnings,
              jit_options=self.jit_options,
          )
          def jit_loss_and_surrogate_loss(*args, **kwargs):
              kwargs.pop("_pyro_model_id")
              kwargs.pop("_pyro_guide_id")
              self = weakself()
              return self._loss_and_surrogate_loss(
                  model, guide, args, kwargs
              )
  
          self._jit_loss_and_surrogate_loss = (
              jit_loss_and_surrogate_loss
          )
  
      elbo, surrogate_loss = self._jit_loss_and_surrogate_loss(
          *args, **kwargs
      )
  
      surrogate_loss.backward(
          retain_graph=self.retain_graph
      )  # triggers jit compilation
  
      loss = -elbo.item()
      warn_if_nan(loss, "loss")
      return 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 1 for calling the JitTraceGraph_ELBO obj's underlying member method code with example usage: obj.loss_and_grads(model, guide) and returns: loss, self