def test_torchscript_properties(modelclass):
    """Test that scripted LightningModule has unnecessary methods removed."""
    model = modelclass()
    script = model.to_torchscript()
    assert not hasattr(model, "batch_size") or hasattr(script, "batch_size")
    assert not hasattr(model, "learning_rate") or hasattr(script, "learning_rate")
    assert not callable(getattr(script, "training_step", None))
Test that scripted LightningModule has unnecessary methods removed.
tests/tests_pytorch/models/test_torchscript.py