code: def compute_site_dice_factor(site):
      log_denom = 0
      log_prob = site["packed"][
          "score_parts"
      ].score_function  # not scaled by subsampling
      dims = getattr(log_prob, "_pyro_dims", "")
      if site["infer"].get("enumerate"):
          num_samples = site["infer"].get("num_samples")
          if num_samples is not None:  # site was multiply sampled
              if not is_identically_zero(log_prob):
                  log_prob = log_prob - log_prob.detach()
              log_prob = log_prob - math.log(num_samples)
              if not isinstance(log_prob, torch.Tensor):
                  log_prob = torch.tensor(
                      float(log_prob), device=site["value"].device
                  )
              log_prob._pyro_dims = dims
              # I don't know why the following broadcast is needed, but it makes tests pass:
              log_prob, _ = packed.broadcast_all(
                  log_prob, site["packed"]["log_prob"]
              )
          elif site["infer"]["enumerate"] == "sequential":
              log_denom = math.log(
                  site["infer"].get("_enum_total", num_samples)
              )
      else:  # site was monte carlo sampled
          if not is_identically_zero(log_prob):
              log_prob = log_prob - log_prob.detach()
              log_prob._pyro_dims = dims
  
      return log_prob, log_denom
  
imports: import math
  import numbers
  from collections import Counter, defaultdict
  from contextlib import contextmanager
  import torch
  from opt_einsum import shared_intermediates
  from opt_einsum.sharing import count_cached_ops
  from pyro.distributions.util import is_identically_zero
  from pyro.ops import packed
  from pyro.ops.einsum.adjoint import require_backward
  from pyro.ops.rings import MarginalRing
  from pyro.poutine.util import site_is_subsample
  from ..None import settings
label_desc: Use image node_id 11 for calling a global function with example usage: compute_site_dice_factor(site) and returns: log_prob,  log_denom