def test_migrate_model_checkpoint_save_on_train_epoch_end_default_collision():
    """Test that the migration warns about collisions that would occur if the keys were modified."""
    # The two keys only differ in the `save_on_train_epoch_end` value
    state_key1 = (
        "ModelCheckpoint{'monitor': None, 'mode': 'min', 'every_n_train_steps': 0, 'every_n_epochs': 1,"
        " 'train_time_interval': None, 'save_on_train_epoch_end': True}"
    )
    state_key2 = (
        "ModelCheckpoint{'monitor': None, 'mode': 'min', 'every_n_train_steps': 0, 'every_n_epochs': 1,"
        " 'train_time_interval': None, 'save_on_train_epoch_end': False}"
    )
    old_checkpoint = {
        "callbacks": {state_key1: {"dummy": 0}, state_key2: {"dummy": 0}},
        "global_step": 0,
        "epoch": 1,
    }
    _set_version(old_checkpoint, "1.8.9")  # pretend a checkpoint prior to 1.9.0
    with pytest.warns(PossibleUserWarning, match="callback states in this checkpoint.* colliding with each other"):
        updated_checkpoint, _ = migrate_checkpoint(old_checkpoint.copy(), target_version="1.9.0")
    assert updated_checkpoint["callbacks"] == old_checkpoint["callbacks"]  # no migration was performed
Test that the migration warns about collisions that would occur if the keys were modified.
tests/tests_pytorch/utilities/migration/test_migration.py