code: def test_scriptable(tmpdir):
      """Test that lightning modules can still be scripted even if metrics cannot."""
  
      class TestModel(BoringModel):
          def __init__(self) -> None:
              super().__init__()
              # the metric is not used in the module's `forward`
              # so the module should be exportable to TorchScript
              self.metric = SumMetric()
              self.register_buffer("sum", torch.tensor(0.0))
  
          def training_step(self, batch, batch_idx):
              x = batch
              self.metric(x.sum())
              self.sum += x.sum()
              self.log("sum", self.metric, on_epoch=True, on_step=False)
              return self.step(x)
  
      model = TestModel()
      trainer = Trainer(
          default_root_dir=tmpdir,
          limit_train_batches=2,
          limit_val_batches=2,
          max_epochs=1,
          log_every_n_steps=1,
          logger=False,
      )
      trainer.fit(model)
      rand_input = torch.randn(10, 32)
  
      script_model = model.to_torchscript()
  
      # test that we can still do inference
      output = model(rand_input)
      script_output = script_model(rand_input)
      assert torch.allclose(output, script_output)
  
imports: from unittest import mock
  import torch
  from lightning_utilities import module_available
  from torch import tensor
  from torch.nn import Linear
  from torchmetrics import MetricCollection
  from torchmetrics.aggregation import SumMetric
  from torchmetrics.classification import BinaryAccuracy, BinaryAveragePrecision
  from torchmetrics.regression import MeanSquaredError
  from torchmetrics.wrappers import MultitaskWrapper
  from integrations.helpers import no_warning_call
  from integrations.lightning.boring_model import BoringModel
label_desc: Use image node_id 6 for calling a global function with example usage: test_scriptable(tmpdir) and returns: self