code: def pyro_method(fn):
      """
      Decorator for top-level methods of a :class:`PyroModule` to enable pyro
      effects and cache ``pyro.sample`` statements.
  
      This should be applied to all public methods that read Pyro-managed
      attributes, but is not needed for ``.forward()``.
      """
  
      @functools.wraps(fn)
      def cached_fn(self, *args, **kwargs):
          with self._pyro_context:
              return fn(self, *args, **kwargs)
  
      return cached_fn
  
imports: import functools
  import inspect
  import weakref
  from collections import OrderedDict, namedtuple
  import torch
  from torch.distributions import constraints, transform_to
  import pyro
  from pyro.ops.provenance import detach_provenance
  from pyro.poutine.runtime import _PYRO_PARAM_STORE
label_desc: Use image node_id 6 for calling a global function with example usage: pyro_method(fn) and returns: cached_fn, fn