def reset(self) -> None:
        """Resets the internal state of the loop for a new run."""
        if (
            self.restarting
            and not self._should_accumulate()
            and (self.restarted_on_train_batch_end or not self.restarted_on_last)
        ):
            # batches_that_stepped is never set prior to saving a checkpoint, even when saving
            # happens on_validation_end
            # we could set it in the checkpoint but we prefer to keep checkpoints backward compatible
            self._batches_that_stepped += 1

        if self.restarted_on_train_batch_end:
            self.batch_progress.increment_completed()
            # handle situation in which save happened on_train_batch_end and epoch is at end
            if self.batch_progress.current.completed >= self.trainer.num_training_batches:
                self.batch_progress.reset_on_run()
                self.scheduler_progress.reset_on_run()
                self.automatic_optimization.optim_progress.reset_on_run()
                self.val_loop.batch_progress.total.reset()

        if self.restarting:
            self.batch_progress.reset_on_restart()
            self.scheduler_progress.reset_on_restart()
            self.automatic_optimization.optim_progress.reset_on_restart()

            trainer = self.trainer
            if trainer.num_training_batches != float("inf"):
                expected_steps = math.ceil(trainer.num_training_batches / trainer.accumulate_grad_batches)
                loader = trainer.fit_loop._combined_loader
                assert loader is not None
                is_resumable_loader = all(isinstance(loader, _Stateful) for loader in loader.flattened)
                if self.global_step % expected_steps != 0 and not is_resumable_loader:
                    rank_zero_warn(
                        "You're resuming from a checkpoint that ended before the epoch ended and your dataloader is"
                        " not resumable. This can cause unreliable results if further training is done."
                        " Consider using an end-of-epoch checkpoint or make your dataloader resumable by implementing"
                        " the `state_dict` / `load_state_dict` interface.",
                        category=PossibleUserWarning,
                    )
        else:
            self.batch_progress.reset_on_run()
            self.scheduler_progress.reset_on_run()
            self.automatic_optimization.optim_progress.reset_on_run()
            # when the epoch starts, the total val batch progress should be reset as it's supposed to count the batches
            # seen per epoch, this is useful for tracking when validation is run multiple times per epoch
            self.val_loop.batch_progress.total.reset()
Resets the internal state of the loop for a new run.
src/lightning/pytorch/loops/training_epoch_loop.py