code: def test_upgrade_checkpoint_directory(
      migrate_mock, load_mock, save_mock, tmp_path
  ):
      top_files = [tmp_path / "top0.ckpt", tmp_path / "top1.ckpt"]
      nested_files = [
          tmp_path / "subdir0" / "nested0.ckpt",
          tmp_path / "subdir0" / "nested1.other",
          tmp_path / "subdir1" / "nested2.ckpt",
      ]
  
      for file in top_files + nested_files:
          file.parent.mkdir(exist_ok=True, parents=True)
          file.touch()
  
      # directory with recursion
      with mock.patch(
          "sys.argv", ["upgrade_checkpoint.py", str(tmp_path)]
      ):
          upgrade_main()
  
      assert {c[0][0] for c in load_mock.call_args_list} == {
          tmp_path / "top0.ckpt",
          tmp_path / "top1.ckpt",
          tmp_path / "subdir0" / "nested0.ckpt",
          tmp_path / "subdir1" / "nested2.ckpt",
      }
      assert migrate_mock.call_count == 4
      assert {c[0][1] for c in save_mock.call_args_list} == {
          tmp_path / "top0.ckpt",
          tmp_path / "top1.ckpt",
          tmp_path / "subdir0" / "nested0.ckpt",
          tmp_path / "subdir1" / "nested2.ckpt",
      }
  
file_path: pytorch-lightning/tests/tests_pytorch/utilities/test_upgrade_checkpoint.py
imports: import logging
  from pathlib import Path
  from unittest import mock
  from unittest.mock import ANY
  import pytest
  import torch
  from lightning.pytorch.utilities.upgrade_checkpoint import main
label_desc: Use image node_id 3 for calling a global function with example usage: test_upgrade_checkpoint_directory(migrate_mock, load_mock, save_mock, tmp_path) without return types