code: def test_auto_restart_under_signal(
      on_last_batch,
      val_check_interval,
      failure_on_training,
      failure_on_step,
      tmpdir,
  ):
      if failure_on_step:
          if on_last_batch:
              if failure_on_training:
                  # Breaking on first validation batch.
                  # This is done to capture the random state of the validation dataloader.
                  status = "_EvaluationLoop:_evaluation_step"
              else:
                  # when breaking on last batch of validation, we should exist on `run_end` val_check_interval == 1.0
                  status = (
                      "_FitLoop:on_advance_end"
                      if val_check_interval == 1.0
                      else "_TrainingEpochLoop:on_advance_end"
                  )
          else:
              status = (
                  "_TrainingEpochLoop:on_advance_end"
                  if failure_on_training
                  else "_EvaluationLoop:_evaluation_step"
              )
      else:
          if val_check_interval == 1.0:
              status = "_FitLoop:on_advance_end"
          else:
              # `on_train_epoch_end` happens after `on_validation_epoch_end` since Lightning v1.4
              status = (
                  "_FitLoop:on_advance_end"
                  if failure_on_training
                  else "_TrainingEpochLoop:on_advance_end"
              )
  
      _fit_model(
          tmpdir,
          True,
          val_check_interval,
          failure_on_step,
          failure_on_training,
          on_last_batch,
          status=status,
      )
  
imports: import inspect
  import pytest
  from lightning.fabric.utilities.seed import seed_everything
  from lightning.pytorch import Callback, Trainer
  from lightning.pytorch.callbacks import OnExceptionCheckpoint
  from lightning.pytorch.demos.boring_classes import BoringModel, RandomDataset
  from lightning.pytorch.utilities.exceptions import SIGTERMException
  from torch.utils.data.dataloader import DataLoader
  from tests_pytorch.helpers.runif import RunIf
label_desc: Use image node_id 2 for calling a global function with example usage: test_auto_restart_under_signal(on_last_batch, val_check_interval, failure_on_training, failure_on_step, tmpdir) without return types