code: def test_scan_checkpoints(
      checkpoint_callback_mock, tmpdir, save_top_k: int
  ):
      """Checks if the expected number of checkpoints is returned."""
      # Test first condition of _scan_checkpoints: if c[1] not in logged_model_time.keys()
      # Test if the returned list of checkpoints has length save_top_k
      best_k_models = {}
      for i in range(save_top_k):
          ckpt_path = tmpdir / f"{i}.ckpt"
          ckpt_path.write("")
          best_k_models[ckpt_path] = i
      checkpoint_callback_mock.best_k_models = best_k_models
  
      logged_model_time = {}
      checkpoints = _scan_checkpoints(
          checkpoint_callback_mock, logged_model_time
      )
      assert len(checkpoints) == save_top_k
  
      # Test second condition of _scan_checkpoints: or logged_model_time[c[1]] < c[0]]
      # Test if the returned list of checkpoints has still size 0
      for c in checkpoints:
          logged_model_time[c[1]] = c[0] + 1000
      checkpoints = _scan_checkpoints(
          checkpoint_callback_mock, logged_model_time
      )
      assert len(checkpoints) == 0
  
imports: import pickle
  from argparse import Namespace
  from copy import deepcopy
  from typing import Any, Dict, Optional
  from unittest.mock import patch
  import numpy
  import pytest
  import torch
  from lightning.fabric.utilities.logger import _convert_params, _sanitize_params
  from lightning.pytorch import Trainer
  from lightning.pytorch.demos.boring_classes import BoringDataModule, BoringModel
  from lightning.pytorch.loggers import Logger, TensorBoardLogger
  from lightning.pytorch.loggers.logger import DummyExperiment, DummyLogger
  from lightning.pytorch.loggers.utilities import _scan_checkpoints
  from lightning.pytorch.utilities.rank_zero import rank_zero_only
label_desc: Use image node_id 11 for calling a global function with example usage: test_scan_checkpoints(checkpoint_callback_mock, tmpdir, save_top_k) without return types