code: def sample(name, fn, *args, **kwargs):
      obs = kwargs.pop("obs", None)
  
      # if there are no active Messengers, we just draw a sample and return it as expected:
      if not PYRO_STACK:
          return fn(*args, **kwargs)
  
      # Otherwise, we initialize a message...
      initial_msg = {
          "type": "sample",
          "name": name,
          "fn": fn,
          "args": args,
          "kwargs": kwargs,
          "value": obs,
      }
  
      # ...and use apply_stack to send it to the Messengers
      msg = apply_stack(initial_msg)
      return msg["value"]
  
imports: import random
  import warnings
  import weakref
  from collections import OrderedDict
  import numpy
  import torch
  from pyro.distributions import validation_enabled
label_desc: Use image node_id 3 for calling a global function with example usage: sample(name, fn) and returns: msg, fn