def on_substep_end(self, args: TrainingArguments, state: TrainerState, control: TrainerControl, **kwargs):
        r"""
        Event called at the end of an substep during gradient accumulation.
        """
        if self.runner is not None and self.runner.aborted:
            control.should_epoch_stop = True
            control.should_training_stop = True

        Event called at the end of an substep during gradient accumulation.
        
src/glmtuner/extras/callbacks.py