code: def test_torchscript_script_recursively():
      class GrandChild(LightningModule):
          def __init__(self):
              super().__init__()
              self.model = torch.nn.Linear(1, 1)
  
          def forward(self, inputs):
              return self.model(inputs)
  
      class Child(LightningModule):
          def __init__(self):
              super().__init__()
              self.model = torch.nn.Sequential(
                  GrandChild(), GrandChild()
              )
  
          def forward(self, inputs):
              return self.model(inputs)
  
      class Parent(LightningModule):
          def __init__(self):
              super().__init__()
              self.model = Child()
  
          def forward(self, inputs):
              return self.model(inputs)
  
      lm = Parent()
      assert not lm._jit_is_scripting
      script = lm.to_torchscript(method="script")
      assert not lm._jit_is_scripting
      assert isinstance(script, torch.jit.RecursiveScriptModule)
  
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 11 for calling a global function with example usage: test_torchscript_script_recursively() and returns: self, self, self