code: def memoize(rule: Callable[[_S], _T]) -> Callable[[_S], _T]:
      """Memoized version of a rule
  
      Notes
      =====
  
      This cache can grow infinitely, so it is not recommended to use this
      than ``functools.lru_cache`` unless you need very heavy computation.
      """
      cache: dict[_S, _T] = {}
  
      def memoized_rl(expr: _S) -> _T:
          if expr in cache:
              return cache[expr]
          else:
              result = rule(expr)
              cache[expr] = result
              return result
  
      return memoized_rl
  
file_path: sympy/sympy/strategies/core.py
imports: from __future__ import annotations
  from collections.abc import Callable, Mapping
  from typing import TypeVar
  from sys import stdout
label_desc: Use image node_id 3 for calling a global function with example usage: memoize(rule) and returns: memoized_rl, cache, result