code: def test_interrupt_state_on_keyboard_interrupt(tmpdir, extra_params):
      """Tests that state is set to INTERRUPTED on KeyboardInterrupt."""
      model = BoringModel()
  
      class InterruptCallback(Callback):
          def on_train_batch_start(
              self, trainer, pl_module, batch, batch_idx
          ):
              raise KeyboardInterrupt
  
      trainer = Trainer(
          callbacks=[InterruptCallback()],
          default_root_dir=tmpdir,
          **extra_params,
      )
  
      trainer.fit(model)
      assert trainer.interrupted
  
imports: import pytest
  from lightning.pytorch import Callback, Trainer
  from lightning.pytorch.demos.boring_classes import BoringModel
  from lightning.pytorch.trainer.states import RunningStage, TrainerFn, TrainerState, TrainerStatus
label_desc: Use image node_id 3 for calling a global function with example usage: test_interrupt_state_on_keyboard_interrupt(tmpdir, extra_params) without return types