Repository: Lightning-AI/pytorch-lightning
File: src/lightning/pytorch/loops/fit_loop.py (Python)

Code before:
        if self._data_fetcher is not None:
            self._data_fetcher.teardown()
            self._data_fetcher = None
        self.epoch_loop.teardown()

    @override
    def on_save_checkpoint(self) -> dict:
        state_dict = super().on_save_checkpoint()
        if self._combined_loader is not None and (loader_states := self._combined_loader._state_dicts()):
            state_dict["combined_loader"] = loader_states
        return state_dict

    @override
    def on_load_checkpoint(self, state_dict: dict) -> None:
        self._combined_loader_states_to_load = state_dict.get("combined_loader", [])
        super().on_load_checkpoint(state_dict)

    def _warn_if_modules_in_eval_mode(self) -> None:
        """Warn if any modules are in eval mode at the start of training."""
        model = self.trainer.lightning_module
        eval_modules = [name for name, module in model.named_modules() if not module.training]

        if eval_modules:
            rank_zero_warn(
                f"Found {len(eval_modules)} module(s) in eval mode at the start of training."
                f" This may lead to unexpected behavior during training. If this is intentional,"
                " you can ignore this warning.",
                category=PossibleUserWarning,
            )

    def _should_accumulate(self) -> bool:
        """Whether the gradients should be accumulated."""
        return self.epoch_loop._should_accumulate()

    def _iteration_based_training(self) -> bool:
        return self.trainer.max_steps != -1

    def _load_combined_loader_states(self) -> None:
        if not self.restarting or not self._combined_loader_states_to_load or self._combined_loader is None:
            return
        self._combined_loader._load_state_dicts(self._combined_loader_states_to_load)
        self._combined_loader_states_to_load = []  # release memory


Review comment (suggestion):
```suggestion
                " This may lead to unexpected behavior during training. If this is intentional,"
```

Code after:
        if self._data_fetcher is not None:
            self._data_fetcher.teardown()
            self._data_fetcher = None
        self.epoch_loop.teardown()

    @override
    def on_save_checkpoint(self) -> dict:
        state_dict = super().on_save_checkpoint()
        if self._combined_loader is not None and (loader_states := self._combined_loader._state_dicts()):
            state_dict["combined_loader"] = loader_states
        return state_dict

    @override
    def on_load_checkpoint(self, state_dict: dict) -> None:
        self._combined_loader_states_to_load = state_dict.get("combined_loader", [])
        super().on_load_checkpoint(state_dict)

    def _warn_if_modules_in_eval_mode(self) -> None:
        """Warn if any modules are in eval mode at the start of training."""
        model = self.trainer.lightning_module
        eval_modules = [name for name, module in model.named_modules() if not module.training]

        if eval_modules:
            rank_zero_warn(
                f"Found {len(eval_modules)} module(s) in eval mode at the start of training."
                " This may lead to unexpected behavior during training. If this is intentional,"
                " you can ignore this warning.",
                category=PossibleUserWarning,
            )

    def _should_accumulate(self) -> bool:
        """Whether the gradients should be accumulated."""
        return self.epoch_loop._should_accumulate()

    def _iteration_based_training(self) -> bool:
        return self.trainer.max_steps != -1

    def _load_combined_loader_states(self) -> None:
        if not self.restarting or not self._combined_loader_states_to_load or self._combined_loader is None:
            return
        self._combined_loader._load_state_dicts(self._combined_loader_states_to_load)
        self._combined_loader_states_to_load = []  # release memory