code: def test_migrate_checkpoint_legacy_version(monkeypatch):
      """Test that the legacy version gets set and does not change if migration is applied multiple times."""
      loaded_checkpoint = {
          "pytorch-lightning_version": "0.0.1",
          "global_step": 2,
          "epoch": 0,
      }
  
      # pretend the current pl version is 2.0
      monkeypatch.setattr(pl, "__version__", "2.0.0")
      new_checkpoint, _ = migrate_checkpoint(loaded_checkpoint)
      assert new_checkpoint["pytorch-lightning_version"] == "2.0.0"
      assert (
          new_checkpoint["legacy_pytorch-lightning_version"] == "0.0.1"
      )
  
      # pretend the current pl version is even newer, we are migrating a second time
      monkeypatch.setattr(pl, "__version__", "3.0.0")
      new_new_checkpoint, _ = migrate_checkpoint(new_checkpoint)
      assert new_new_checkpoint["pytorch-lightning_version"] == "3.0.0"
      assert (
          new_new_checkpoint["legacy_pytorch-lightning_version"]
          == "0.0.1"
      )
  
imports: import glob
  import logging
  import os
  import pickle
  import sys
  from unittest.mock import ANY
  import lightning.pytorch
  import pytest
  import torch
  from lightning.fabric.utilities.warnings import PossibleUserWarning
  from lightning.pytorch.utilities.migration import migrate_checkpoint, pl_legacy_patch
  from lightning.pytorch.utilities.migration.utils import _pl_migrate_checkpoint, _RedirectingUnpickler
  from lightning_utilities.core.imports import module_available
  from lightning_utilities.test.warning import no_warning_call
  from packaging.version import Version
  from tests_pytorch.checkpointing.test_legacy_checkpoints import CHECKPOINT_EXTENSION, LEGACY_BACK_COMPATIBLE_PL_VERSIONS, LEGACY_CHECKPOINTS_PATH
label_desc: Use image node_id 12 for calling a global function with example usage: test_migrate_checkpoint_legacy_version(monkeypatch) without return types