def test_torchscript_retain_training_state():
    """Test that torchscript export does not alter the training mode of original model."""
    model = BoringModel()
    model.train(True)
    script = model.to_torchscript()
    assert model.training
    assert not script.training
    model.train(False)
    _ = model.to_torchscript()
    assert not model.training
    assert not script.training
Test that torchscript export does not alter the training mode of original model.
tests/tests_pytorch/models/test_torchscript.py