code: def cached(func):
      
      ret = None
  
      def call_or_cache(*args, **kwargs):
          nonlocal ret
          if ret is None:
              ret = func(*args, **kwargs)
          return ret
  
      return call_or_cache
docs: Memoize a function result.