code: def AutoFileLock(
      lock_file: Union[str, os.PathLike], timeout: float = -1
  ) -> BaseFileLock:
      """
      Returns a file lock based on the file system type of the given path.
  
      If the file system of the given path is not capable of using `fcntl` locks,
      a soft file lock is used.
  
      If the file system type of the given path is failed to be determined,
      a soft file lock is used.
  
  
      :param lock_file: path to the file
      :param timeout: default timeout when acquiring the lock. It will be used as
          fallback value in the acquire method, if no timeout value (``None``) is
          given. If you want to disable the timeout, set it to a negative value.
          A timeout of 0 means, that there is exactly one attempt to acquire the
          file lock.
      """
      if not FileSystemInspector.needs_soft_lock(lock_file):
          return UnixFileLock(lock_file, timeout)
      else:
          # Cleaning lock files is not required by `FileLock`. The leftover lock files
          # (potentially from previous versions) could be interpreted as *acquired*
          # locks by `SoftFileLock` causing a deadlock.
          # To prevent this, we add a suffix to the lock file name.
          return SoftFileLock(f"{lock_file}.softlock", timeout)
  
imports: import os
  import logging
  import pathlib
  import threading
  import uuid
  import time
  from filelock import BaseFileLock, SoftFileLock, UnixFileLock, has_fcntl
  from cachetools.func import ttl_cache
  from psutil import disk_partitions
  from typing import Optional, Union, Dict, Set, Tuple
label_desc: Use image node_id 1 for calling a global function with example usage: AutoFileLock(lock_file, timeout) and returns: UnixFileLock, SoftFileLock