code: def _get_sample_fn(module, name):
      if module.mode == "model":
          return module._priors[name]
  
      dist_constructor, dist_args = module._guides[name]
  
      if dist_constructor is dist.Delta:
          p_map = getattr(module, "{}_map".format(name))
          return dist.Delta(p_map, event_dim=p_map.dim())
  
      # create guide
      dist_args = {
          arg: getattr(module, "{}_{}".format(name, arg))
          for arg in dist_args
      }
      guide = dist_constructor(**dist_args)
  
      # no need to do transforms when support is real (for mean field ELBO)
      support = module._priors[name].support
      if _is_real_support(support):
          return guide.to_event()
  
      # otherwise, we do inference in unconstrained space and transform the value
      # back to original space
      # TODO: move this logic to infer.autoguide or somewhere else
      unconstrained_value = pyro.sample(
          module._pyro_get_fullname("{}_latent".format(name)),
          guide.to_event(),
          infer={"is_auxiliary": True},
      )
      transform = biject_to(support)
      value = transform(unconstrained_value)
      log_density = transform.inv.log_abs_det_jacobian(
          value, unconstrained_value
      )
      return dist.Delta(value, log_density.sum(), event_dim=value.dim())
  
imports: import warnings
  from collections import OrderedDict
  from functools import partial
  from torch.distributions import biject_to, constraints
  from torch.nn import Parameter
  import pyro
  import pyro.distributions
  from pyro.distributions.util import eye_like
  from pyro.nn.module import PyroModule, PyroParam, PyroSample, pyro_method
label_desc: Use image node_id 2 for calling a global function with example usage: _get_sample_fn(module, name) and returns: dist, module, dist, guide