code: def init_to_mean(
      site=None,
      *,
      fallback: Optional[Callable] = init_to_median,
  ):
      """
      Initialize to the prior mean; fallback to ``fallback`` (defaults to
      :func:`init_to_median`) if mean is undefined.
  
      :param callable fallback: Fallback init strategy, for sites not specified
          in ``values``.
      :raises ValueError: If ``fallback=None`` and no value for a site is given
          in ``values``.
      """
      if site is None:
          return functools.partial(init_to_mean, fallback=fallback)
  
      try:
          # Try .mean() method.
          value = site["fn"].mean.detach()
          if torch_isnan(value):
              raise ValueError
          if hasattr(site["fn"], "_validate_sample"):
              site["fn"]._validate_sample(value)
          value._pyro_custom_init = False
          return value
      except (NotImplementedError, ValueError):
          # This may happen for distributions with infinite variance, e.g. Cauchy.
          pass
      if fallback is not None:
          return fallback(site)
      raise ValueError(
          f"No init strategy specified for site {repr(site['name'])}"
      )
  
imports: import functools
  from typing import Callable, Optional
  import torch
  from torch.distributions import transform_to
  from pyro.distributions.torch import Independent
  from pyro.distributions.torch_distribution import MaskedDistribution
  from pyro.infer.util import is_validation_enabled
  from pyro.poutine.messenger import Messenger
  from pyro.util import torch_isnan
  from .utils import helpful_support_errors
label_desc: Use image node_id 5 for calling a global function with example usage: init_to_mean(site) and returns: functools, value, fallback