code: def test_multiprocess_to_directory(checkpoint: Checkpoint):
      """Test the case where multiple processes are trying to checkpoint.
  
      Only one process should download the checkpoint, and the others should
      wait until it's finished. In the end, a single checkpoint dir should be
      shared by all processes.
      """
      if checkpoint.filesystem.type_name == "mock":
          pytest.skip(
              "Mock filesystem cannot be pickled for use with Ray."
          )
  
      @ray.remote
      def download_checkpoint(checkpoint: Checkpoint) -> str:
          return checkpoint.to_directory()
  
      paths = [
          ray.get(download_checkpoint.remote(checkpoint))
          for _ in range(5)
      ]
      # Check that all the paths are the same (no duplicates).
      assert len(set(paths)) == 1
  
file_path: ray/python/ray/train/tests/test_checkpoint.py
imports: import os
  from pathlib import Path
  import pyarrow.fs
  import pytest
  import ray
  from ray.train._checkpoint import _CHECKPOINT_TEMP_DIR_PREFIX, _METADATA_FILE_NAME, Checkpoint, _get_del_lock_path, _list_existing_del_locks
  from ray.train._internal.storage import _exists_at_fs_path, _upload_to_fs_path
  from ray.train.tests.test_new_persistence import _create_mock_custom_fs
label_desc: Use image node_id 4 for calling a global function with example usage: test_multiprocess_to_directory(checkpoint) and returns: checkpoint