code: def methodof(cls, name=None):
      """
      Decorator to set the named method of the given class. Can be stacked.
  
      Example usage::
  
         @methodof(MyClass)
         def __call__(self, x):
             return x
      """
  
      def decorator(fn):
          name_ = name
          if name_ is None:
              fn_ = fn
              while not hasattr(fn_, "__name__"):
                  if isinstance(fn_, property):
                      fn_ = fn_.fget
                  else:
                      fn_ = fn_.__func__
              name_ = fn_.__name__
          setattr(cls, name_, fn)
          return fn
  
      return decorator
  
imports: import functools
  import inspect
  import pprint
  import re
  import sys
  import numpy
label_desc: Use image node_id 19 for calling a global function with example usage: methodof(cls, name) and returns: decorator, fn