def METHOD_NAME(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)