code: def _memoize(f: Callable) -> Callable:
      memo = {}
  
      @functools.wraps(f)
      def ret(*args: Any, **kwargs: Any) -> Any:
          key = (args, frozenset(kwargs.items()))
          if key not in memo:
              memo[key] = f(*args, **kwargs)
          return memo[key]
  
      return ret
  
imports: import functools
  import glob
  import os
  import sys
  from typing import Any, Callable, Optional
label_desc: Use image node_id 1 for calling a global function with example usage: _memoize(f) and returns: ret, memo