code: def memoize(fun):
      """A simple memoize decorator for functions supporting (hashable)
      positional arguments.
      It also provides a cache_clear() function for clearing the cache:
  
      >>> @memoize
      ... def foo()
      ...     return 1
          ...
      >>> foo()
      1
      >>> foo.cache_clear()
      >>>
      """
  
      @functools.wraps(fun)
      def wrapper(*args, **kwargs):
          key = (args, frozenset(sorted(kwargs.items())))
          try:
              return cache[key]
          except KeyError:
              ret = cache[key] = fun(*args, **kwargs)
              return ret
  
      def cache_clear():
          """Clear cache."""
          cache.clear()
  
      cache = {}
      wrapper.cache_clear = cache_clear
      return wrapper
  
imports: from __future__ import division, print_function
  import contextlib
  import errno
  import functools
  import os
  import socket
  import stat
  import sys
  import threading
  import warnings
  from collections import defaultdict
  from collections import namedtuple
  from socket import AF_INET
  from socket import SOCK_DGRAM
  from socket import SOCK_STREAM
label_desc: Use image node_id 2 for calling a global function with example usage: memoize(fun) and returns: wrapper, cache, ret