code: def cache(
      name: str,
      loader: Optional[Callable[[], Any]] = None,
      *,
      file_type: str = "json",
  ) -> Any:
      """
      This caches results of a function. Can be used as a decorator or you can pass a lambda function
      to it that takes no arguments.
  
      *It doesn't cache by arguments.*
  
      Arguments:
          name (str): name of the cache
          loader (Callable[[], Any], optional): the function that generates the data to be cached
  
      Keyword Arguments:
          file_type (str, optional): The file type to store the data. Defaults to ``json``.
      """
      if loader is not None:
          return _cache_wrap(name, loader, file_type=file_type)
  
      def decorator_func(f: Callable):
          @functools.wraps(f)
          def wrapper(*args, **kwargs):
              path = _get_cache_path(name, file_type)
              if path.exists():
                  return _cache_load(path, file_type)
              else:
                  value = f(*args, **kwargs)
                  _cache_save(path, value, file_type)
  
                  return value
  
          return wrapper
  
      return decorator_func
  
file_path: labml/client/labml/utils/cache.py
imports: import functools
  import json
  import pickle
  from pathlib import Path
  from typing import Callable, Any, Optional
  from labml import lab
label_desc: Use image node_id 5 for calling a global function with example usage: cache(name, loader) and returns: decorator_func, _cache_wrap, wrapper, _cache_load, value