code: def module_method(fn, name=None):
      if name is None:
          name = fn.__name__ if hasattr(fn, "__name__") else None
  
      def wrapper(self, *args, **kwargs):
          scope = self.scope.rewound()
          mod_fn = lambda scope: fn(self, scope, *args, **kwargs)
          return scope.child(mod_fn, name)()
  
      return wrapper
  
imports: from dataclasses import dataclass
  from typing import Callable
  import jax
  from absl.testing import absltest
  from jax import numpy
  from jax import random
  from flax.core import Array, Scope, init, nn, unfreeze
label_desc: Use image node_id 2 for calling a global function with example usage: module_method(fn, name) and returns: wrapper, scope