code: def _compute_log_r(model_trace, guide_trace):
      log_r = MultiFrameTensor()
      stacks = get_plate_stacks(model_trace)
      for name, model_site in model_trace.nodes.items():
          if model_site["type"] == "sample":
              log_r_term = model_site["log_prob"]
              if not model_site["is_observed"]:
                  log_r_term = (
                      log_r_term - guide_trace.nodes[name]["log_prob"]
                  )
              log_r.add((stacks[name], log_r_term.detach()))
      return log_r
  
imports: import weakref
  import pyro
  import pyro.ops.jit
  from pyro.distributions.util import is_identically_zero
  from pyro.infer.elbo import ELBO
  from pyro.infer.enum import get_importance_trace
  from pyro.infer.util import MultiFrameTensor, get_plate_stacks, is_validation_enabled, torch_item
  from pyro.util import check_if_enumerated, warn_if_nan
label_desc: Use image node_id 1 for calling a global function with example usage: _compute_log_r(model_trace, guide_trace) and returns: log_r