code: def get_unique_file_path(
      dir_path, file_pattern, create_file=True, max_suffix=10000
  ):
      def atomic_file_create(path):
          try:
              fd = os.open(path, os.O_CREAT | os.O_EXCL, 0o644)
              os.close(fd)
              return True
          except OSError as e:
              if e.errno in [errno.EEXIST, errno.EISDIR, errno.ETXTBSY]:
                  return False
              # Access issue with file itself, not parent directory.
              if e.errno == errno.EACCES and os.path.exists(path):
                  return False
              raise e
  
      def atomic_dir_create(path):
          try:
              os.mkdir(path)
              return True
          except OSError as e:
              if e.errno == errno.EEXIST:
                  return False
              raise e
  
      file_path = os.path.join(dir_path, file_pattern)
      lpf.ensure_dir(os.path.dirname(file_path))
      file_counter = 0
      handler = atomic_file_create if create_file else atomic_dir_create
      while os.path.exists(file_path) or not handler(file_path):
          file_path = os.path.join(
              dir_path, file_pattern + ".{}".format(file_counter)
          )
          file_counter += 1
          assert file_counter < max_suffix
      return file_path
  
file_path: catboost/library/python/testing/yatest_common/yatest/common/path.py
imports: import errno
  import os
  import shutil
  import contextlib
  import library.python.fs
label_desc: Use image node_id 4 for calling a global function with example usage: get_unique_file_path(dir_path, file_pattern, create_file, max_suffix) and returns: file_path, True, True, False, False, False