code: def test_limited_checkpoints(checkpoint_paths: List[str]):
      manager = _CheckpointManager(
          checkpoint_config=CheckpointConfig(num_to_keep=2)
      )
  
      for i in range(10):
          manager.register_checkpoint(
              _TrainingResult(
                  checkpoint=Checkpoint.from_directory(
                      checkpoint_paths[i]
                  ),
                  metrics={"iter": i},
              )
          )
  
      assert len(manager.best_checkpoint_results) == 2
  
      # Keep the latest checkpoints if no metric is given.
      assert {
          tracked_checkpoint.metrics["iter"]
          for tracked_checkpoint in manager.best_checkpoint_results
      } == {8, 9}
  
      # The first 8 checkpoints should be deleted.
      for i in range(8):
          assert not Path(checkpoint_paths[i]).exists()
  
      assert Path(checkpoint_paths[8]).exists()
      assert Path(checkpoint_paths[9]).exists()
  
file_path: ray/python/ray/train/tests/test_checkpoint_manager.py
imports: import random
  from pathlib import Path
  from typing import List
  import pytest
  from ray.train import Checkpoint, CheckpointConfig
  from ray.train._internal.checkpoint_manager import _CheckpointManager, _TrainingResult
label_desc: Use image node_id 3 for calling a global function with example usage: test_limited_checkpoints(checkpoint_paths) without return types