code: def _check_overwrite_error(
      ckpt_tmp_path: str, ckpt_path: str, base_path: str, step: int
  ):
      """Throw error if a ckpt file of this step or higher already exists."""
      dir_path, prefix = os.path.split(base_path)
      checkpoint_files: List[Any] = [
          pathlib.PurePath(c) for c in _allowempty_listdir(dir_path)
      ]
      checkpoint_files = [
          os.path.join(dir_path, c)
          for c in checkpoint_files
          if c.match(f"{prefix}*")
          and not c.match(f"*{MP_ARRAY_POSTFIX}")
      ]
      if ckpt_path in checkpoint_files:
          raise errors.InvalidCheckpointError(ckpt_path, step)
      checkpoint_files.append(ckpt_path)
  
      checkpoint_files = natural_sort(checkpoint_files)
      # Handle the case if the job was preempted after the temporary checkpoint
      # was written, but before it was renamed to the final checkpoint name
      if checkpoint_files[-1] == ckpt_tmp_path:
          checkpoint_files.pop()
      if ckpt_path != checkpoint_files[-1]:
          raise errors.InvalidCheckpointError(ckpt_path, step)
  
imports: import functools
  import os
  import pathlib
  import re
  import time
  import warnings
  from concurrent.futures import thread
  from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Type, Union
  import jax
  import orbax.checkpoint
  from absl import logging
  from jax import monitoring, process_index
  from jax import tree_util
  from jax.experimental.array_serialization.serialization import GlobalAsyncCheckpointManager, get_tensorstore_spec
  from jax.experimental.multihost_utils import sync_global_devices
  from flax import config, core, errors, io, serialization, traverse_util
  from flax.training import orbax_utils
label_desc: Use image node_id 15 for calling a global function with example usage: _check_overwrite_error(ckpt_tmp_path, ckpt_path, base_path, step) without return types