code: def wait_filepath(path, exist=True):
      """
      等待当 path 的存在状态为 {exist} 时返回
  
      :param path: 待检测的 path
      :param exist: 为 True 时表明检测这个 path 存在就返回; 为 False 表明检测到这个 path 不存在 返回。
      :return:
      """
      if isinstance(path, str):
          path = Path(path)
      assert isinstance(path, Path)
      count = 0
      while True:
          sleep(0.01)
          if path.exists() == exist:
              break
          count += 1
          if count % 1000 == 0:
              msg = "create" if exist else "delete"
              logger.warning(
                  f"Waiting path:{path} to {msg} for {count*0.01} seconds..."
              )
  
imports: import functools
  import inspect
  from inspect import Parameter
  import dataclasses
  from dataclasses import is_dataclass
  from copy import deepcopy
  from collections import defaultdict, OrderedDict
  from typing import Callable, List, Any, Dict, AnyStr, Union, Mapping, Sequence
  from typing import Tuple, Optional
  from time import sleep
  import os
  from contextlib import contextmanager
  from functools import wraps
  from prettytable import PrettyTable
  from pathlib import Path
  from fastNLP.core.log import logger
label_desc: Use image node_id 17 for calling a global function with example usage: wait_filepath(path, exist) without return types