code: def test_signal_handlers_restored_in_teardown():
      """Test that the SignalConnector restores the previously configured handler on teardown."""
      assert signal.getsignal(signal.SIGTERM) is signal.SIG_DFL
  
      trainer = Trainer(plugins=SLURMEnvironment())
      connector = _SignalConnector(trainer)
      connector.register_signal_handlers()
  
      assert signal.getsignal(signal.SIGTERM) is not signal.SIG_DFL
      connector.teardown()
      assert signal.getsignal(signal.SIGTERM) is signal.SIG_DFL
  
imports: import concurrent.futures
  import os
  import signal
  from unittest import mock
  from unittest.mock import Mock
  import pytest
  from lightning.fabric.plugins.environments import SLURMEnvironment
  from lightning.fabric.utilities.imports import _IS_WINDOWS
  from lightning.pytorch import Trainer
  from lightning.pytorch.demos.boring_classes import BoringModel
  from lightning.pytorch.trainer.connectors.signal_connector import _SignalConnector
  from lightning.pytorch.utilities.exceptions import SIGTERMException
  from tests_pytorch.helpers.runif import RunIf
label_desc: Use image node_id 1 for calling a global function with example usage: test_signal_handlers_restored_in_teardown() without return types