code: def _safe(fn):
      """
      Safe version of utilities in the :mod:`pyro.ops.stats` module. Wrapped
      functions return `NaN` tensors instead of throwing exceptions.
  
      :param fn: stats function from :mod:`pyro.ops.stats` module.
      """
  
      @functools.wraps(fn)
      def wrapped(sample, *args, **kwargs):
          try:
              val = fn(sample, *args, **kwargs)
          except Exception:
              warnings.warn(tb.format_exc())
              val = torch.full(
                  sample.shape[2:],
                  float("nan"),
                  dtype=sample.dtype,
                  device=sample.device,
              )
          return val
  
      return wrapped
  
imports: import functools
  import traceback
  import warnings
  from collections import OrderedDict, defaultdict
  from functools import partial, reduce
  from itertools import product
  import torch
  from opt_einsum import shared_intermediates
  from torch.distributions import biject_to
  import pyro
  import pyro.poutine
  from pyro.distributions.util import broadcast_shape, logsumexp
  from pyro.infer import config_enumerate
  from pyro.infer.autoguide.initialization import InitMessenger, init_to_uniform
  from pyro.infer.util import is_validation_enabled
  from pyro.ops import stats
  from pyro.ops.contract import contract_to_tensor
  from pyro.ops.integrator import potential_grad
  from pyro.poutine.subsample_messenger import _Subsample
  from pyro.poutine.util import prune_subsample_sites
  from pyro.util import check_site_shape, ignore_jit_warnings
label_desc: Use image node_id 4 for calling a global function with example usage: _safe(fn) and returns: wrapped, val