code: def compile_cache(cacheable_fn):
      cache = weakref.WeakKeyDictionary()
      internal_caches.append(cache)
  
      def cached_fn_impl(leaves, treedef):
          user_fn_names, args, kwargs = jtu.tree_unflatten(
              treedef, leaves
          )
          return cacheable_fn(user_fn_names, *args, **kwargs)
  
      @ft.wraps(cacheable_fn)
      def wrapped_cacheable_fn(user_fn, *args, **kwargs):
          user_fn_names = get_fn_names(user_fn)
          leaves, treedef = jtu.tree_flatten(
              (user_fn_names, args, kwargs)
          )
          leaves = tuple(leaves)
  
          # Best-effort attempt to clear the cache of old and unused entries.
          if type(user_fn) is types.FunctionType:
              cache_key = user_fn
          else:
              cache_key = _default_cache_key
  
          try:
              cached_fn = cache[cache_key]
          except KeyError:
              cached_fn = cache[cache_key] = ft.lru_cache(maxsize=None)(
                  cached_fn_impl
              )
          return cached_fn(leaves, treedef)
  
      def delete(user_fn):
          user_fn = _strip_wrapped_partial(user_fn)
          if type(user_fn) is types.FunctionType:
              try:
                  del cache[user_fn]
              except KeyError:
                  warnings.warn(
                      f"Could not delete cache for function {user_fn}. Has it already "
                      "been deleted?"
                  )
          else:
              warnings.warn("Could not delete non-function from cache.")
  
      wrapped_cacheable_fn.delete = delete  # pyright: ignore
      return wrapped_cacheable_fn
  
imports: import functools
  import types
  import warnings
  import weakref
  from collections.abc import Callable
  import jax
  import jax.tree_util
  from jaxtyping import PyTree
  from ._caches import internal_caches
  from ._module import Module
label_desc: Use image node_id 7 for calling a global function with example usage: compile_cache(cacheable_fn) and returns: wrapped_cacheable_fn, cacheable_fn, cached_fn