code: def ensure_path(path, mode=0o777):
      
  
      if path:
          try:
              umask = os.umask(000)
              os.makedirs(path, mode)
              os.umask(umask)
          except OSError as e:
              if e.errno != errno.EEXIST:
                  raise
docs: Ensure that path exists in a multiprocessing safe way.
  
      If the path does not exist, recursively create it and its parent
      directories using the provided mode.  If the path already exists,
      do nothing.  The umask is cleared to enable the mode to be set,
      and then reset to the original value after the mode is set.
  
      Parameters
      ----------
      path : str
          file system path to a non-existent directory
          that should be created.
      mode : int
          octal representation of the mode to use when creating
          the directory.
  
      Raises
      ------
      OSError
          If os.makedirs raises an OSError for any reason
          other than if the directory already exists.