docs: def _memoize_function(f, name, cache_scope=_CS_FOREVER):
      """
      Wraps a function for memoization and ties it's cache into the
      Orca cacheing system.
  
      Parameters
      ----------
      f : function
      name : str
          Name of injectable.
      cache_scope : {'step', 'iteration', 'forever'}, optional
          Scope for which to cache data. Default is to cache forever
          (or until manually cleared). 'iteration' caches data for each
          complete iteration of the pipeline, 'step' caches data for
          a single step of the pipeline.
  
      """
      cache = {}
  
      @wraps(f)
      def wrapper(*args, **kwargs):
          try:
              cache_key = (
                  args or None, frozenset(kwargs.items()) if kwargs else None)
              in_cache = cache_key in cache
          except TypeError:
              raise TypeError(
                  'function arguments must be hashable for memoization')
  
          if _CACHING and in_cache:
              return cache[cache_key]
          else:
              result = f(*args, **kwargs)
              cache[cache_key] = result
              return result
  
      wrapper.__wrapped__ = f
      wrapper.cache = cache
      wrapper.clear_cached = lambda: cache.clear()
      _MEMOIZED[name] = CacheItem(name, wrapper, cache_scope)
  
      return wrapper