def test_model_torch_save(tmp_path):
    """Test to ensure torch save does not fail for model and trainer."""
    model = BoringModel()
    num_epochs = 1
    trainer = Trainer(default_root_dir=tmp_path, max_epochs=num_epochs)
    temp_path = tmp_path / "temp.pt"
    trainer.fit(model)

    # Ensure these do not fail
    torch.save(trainer.model, temp_path)
    torch.save(trainer, temp_path)
    trainer = torch.load(temp_path, weights_only=False)
Test to ensure torch save does not fail for model and trainer.
tests/tests_pytorch/checkpointing/test_torch_saving.py