code: def memoized_method(func):
      """
      A decorator that performs memoization on methods. It stores the cache on the object instance itself.
      """
  
      @functools.wraps(func)
      def wrapper(*args, **kwargs):
          self = args[0]
          assert func.__name__ in dir(
              self
          ), "memoized_method can only be used on method!"
  
          if not hasattr(self, "_MEMOIZED_CACHE"):
              cache = self._MEMOIZED_CACHE = {}
          else:
              cache = self._MEMOIZED_CACHE
  
          key = (func,) + args[1:] + tuple(kwargs)
          ret = cache.get(key, None)
          if ret is not None:
              return ret
          value = func(*args, **kwargs)
          cache[key] = value
          return value
  
      return wrapper
  
file_path: tensorpack/tensorpack/utils/argtools.py
imports: import inspect
  import functools
  from .None import logger
label_desc: Use image node_id 9 for calling a global function with example usage: memoized_method(func) and returns: wrapper, value, ret