code: 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
  
imports: import os
  import fsspec
  import pytest
  import torch
  from fsspec.implementations.local import LocalFileSystem
  from lightning.fabric.utilities.cloud_io import get_filesystem
  from lightning.pytorch.core.module import LightningModule
  from lightning.pytorch.demos.boring_classes import BoringModel
  from tests_pytorch.helpers.advanced_models import BasicGAN, ParityModuleRNN
  from tests_pytorch.helpers.runif import RunIf
label_desc: Use image node_id 5 for calling a global function with example usage: test_torchscript_retain_training_state() without return types