code: def memoize(f):
      """
      Cache the return value for each tuple of arguments (which must be hashable).
  
      """
      cache = {}
  
      def rval(*args, **kwargs):
          kwtup = tuple(kwargs.items())
          key = (args, kwtup)
          if key not in cache:
              val = f(*args, **kwargs)
              cache[key] = val
          else:
              val = cache[key]
          return val
  
      return rval
  
imports: from __future__ import absolute_import, print_function, division
  import linecache
  import sys
  import traceback
  import numpy
  from six import iteritems, integer_types, string_types, with_metaclass
  from six.moves import StringIO
  from theano import config
  from theano.compat import PY3
label_desc: Use image node_id 5 for calling a global function with example usage: memoize(f) and returns: rval, val