code: def cache_or_load_file(path, creator, loader):
      """Caches a file if it does not exist, or loads it otherwise.
  
      This is a utility function used in dataset loading routines. The
      ``creator`` creates the file to given path, and returns the content. If the
      file already exists, the ``loader`` is called instead, and it loads the
      file and returns the content.
  
      Note that the path passed to the creator is temporary one, and not same as
      the path given to this function. This function safely renames the file
      created by the creator to a given path, even if this function is called
      simultaneously by multiple threads or processes.
  
      Args:
          path (str): Path to save the cached file.
          creator: Function to create the file and returns the content. It takes
              a path to temporary place as the argument. Before calling the
              creator, there is no file at the temporary path.
          loader: Function to load the cached file and returns the content.
  
      Returns:
          It returns the returned values by the creator or the loader.
  
      """
      if os.path.exists(path):
          return loader(path)
  
      try:
          os.makedirs(_dataset_root)
      except OSError:
          if not os.path.isdir(_dataset_root):
              raise RuntimeError("cannot create dataset directory")
  
      lock_path = os.path.join(_dataset_root, "_create_lock")
  
      with utils.tempdir() as temp_dir:
          file_name = os.path.basename(path)
          temp_path = os.path.join(temp_dir, file_name)
          content = creator(temp_path)
          with filelock.FileLock(lock_path):
              if not os.path.exists(path):
                  shutil.move(temp_path, path)
  
      return content
  
file_path: chainer/chainer/dataset/download.py
imports: import hashlib
  import os
  import shutil
  import sys
  import filelock
  from six.moves.urllib import request
  from chainer import utils
label_desc: Use image node_id 5 for calling a global function with example usage: cache_or_load_file(path, creator, loader) and returns: content, loader