def test_load_from_checkpoint_strict(strict, strict_loading, expected, tmp_path):
    """Test that strict loading works both with the `strict` argument and the model's `strict_loading` attribute."""

    class LoadingModel(BoringModel):
        def __init__(self):
            super().__init__()
            self.strict_loading = strict_loading

    LoadingModel.load_state_dict = Mock()

    create_boring_checkpoint(tmp_path, LoadingModel(), accelerator="cpu")

    if expected == "error":
        with pytest.raises(ValueError, match="in conflict with .*strict_loading"):
            LoadingModel.load_from_checkpoint(tmp_path / "checkpoint.ckpt", strict=strict)
    else:
        model = LoadingModel.load_from_checkpoint(tmp_path / "checkpoint.ckpt", strict=strict)
        model.load_state_dict.assert_called_once_with(ANY, strict=expected)
Test that strict loading works both with the `strict` argument and the model's `strict_loading` attribute.
tests/tests_pytorch/core/test_saving.py