code: def context_dependent_memoize(func):
      def wrapper(*args, **kwargs):
          if kwargs:
              cache_key = (args, frozenset(kwargs.items()))
          else:
              cache_key = (args,)
  
          try:
              ctx_dict = func._pycuda_ctx_dep_memoize_dic
          except AttributeError:
              # FIXME: This may keep contexts alive longer than desired.
              # But I guess since the memory in them is freed, who cares.
              ctx_dict = func._pycuda_ctx_dep_memoize_dic = {}
  
          cur_ctx = cuda.Context.get_current()
  
          try:
              return ctx_dict[cur_ctx][cache_key]
          except KeyError:
              context_dependent_memoized_functions.append(func)
              arg_dict = ctx_dict.setdefault(cur_ctx, {})
              result = func(*args, **kwargs)
              arg_dict[cache_key] = result
              return result
  
      from functools import update_wrapper
  
      update_wrapper(wrapper, func)
      return wrapper
  
imports: import pycuda.driver
  import pycuda._driver
  import numpy
  from pycuda.compyte.dtypes import register_dtype, get_or_register_dtype, _fill_dtype_registry, dtype_to_ctype
label_desc: Use image node_id 9 for calling a global function with example usage: context_dependent_memoize(func) and returns: wrapper, ctx_dict, result