def fit(
        self,
        model: "pl.LightningModule",
        train_dataloaders: Optional[Union[TRAIN_DATALOADERS, LightningDataModule]] = None,
        val_dataloaders: Optional[EVAL_DATALOADERS] = None,
        datamodule: Optional[LightningDataModule] = None,
        ckpt_path: Optional[_PATH] = None,
    ) -> None:
        r"""Runs the full optimization routine.

        Args:
            model: Model to fit.

            train_dataloaders: An iterable or collection of iterables specifying training samples.
                Alternatively, a :class:`~lightning.pytorch.core.datamodule.LightningDataModule` that defines
                the :class:`~lightning.pytorch.core.hooks.DataHooks.train_dataloader` hook.

            val_dataloaders: An iterable or collection of iterables specifying validation samples.

            datamodule: A :class:`~lightning.pytorch.core.datamodule.LightningDataModule` that defines
                the :class:`~lightning.pytorch.core.hooks.DataHooks.train_dataloader` hook.

            ckpt_path: Path/URL of the checkpoint from which training is resumed. Could also be one of two special
                keywords ``"last"``, ``"hpc"`` and ``"registry"``.
                Otherwise, if there is no checkpoint file at the path, an exception is raised.

                    - best: the best model checkpoint from the previous ``trainer.fit`` call will be loaded
                    - last: the last model checkpoint from the previous ``trainer.fit`` call will be loaded
                    - registry: the model will be downloaded from the Lightning Model Registry with following notations:

                        - ``'registry'``: uses the latest/default version of default model set
                          with ``Tainer(..., model_registry="my-model")``
                        - ``'registry:model-name'``: uses the latest/default version of this model `model-name`
                        - ``'registry:model-name:version:v2'``: uses the specific version 'v2' of the model `model-name`
                        - ``'registry:version:v2'``: uses the default model set
                          with ``Tainer(..., model_registry="my-model")`` and version 'v2'


        Raises:
            TypeError:
                If ``model`` is not :class:`~lightning.pytorch.core.LightningModule` for torch version less than
                2.0.0 and if ``model`` is not :class:`~lightning.pytorch.core.LightningModule` or
                :class:`torch._dynamo.OptimizedModule` for torch versions greater than or equal to 2.0.0 .

        For more information about multiple dataloaders, see this :ref:`section <multiple-dataloaders>`.

        """
        model = _maybe_unwrap_optimized(model)
        self.strategy._lightning_module = model
        _verify_strategy_supports_compile(model, self.strategy)
        self.state.fn = TrainerFn.FITTING
        self.state.status = TrainerStatus.RUNNING
        self.training = True
        self.should_stop = False
        call._call_and_handle_interrupt(
            self, self._fit_impl, model, train_dataloaders, val_dataloaders, datamodule, ckpt_path
        )
Runs the full optimization routine.

        Args:
            model: Model to fit.

            train_dataloaders: An iterable or collection of iterables specifying training samples.
                Alternatively, a :class:`~lightning.pytorch.core.datamodule.LightningDataModule` that defines
                the :class:`~lightning.pytorch.core.hooks.DataHooks.train_dataloader` hook.

            val_dataloaders: An iterable or collection of iterables specifying validation samples.

            datamodule: A :class:`~lightning.pytorch.core.datamodule.LightningDataModule` that defines
                the :class:`~lightning.pytorch.core.hooks.DataHooks.train_dataloader` hook.

            ckpt_path: Path/URL of the checkpoint from which training is resumed. Could also be one of two special
                keywords ``"last"``, ``"hpc"`` and ``"registry"``.
                Otherwise, if there is no checkpoint file at the path, an exception is raised.

                    - best: the best model checkpoint from the previous ``trainer.fit`` call will be loaded
                    - last: the last model checkpoint from the previous ``trainer.fit`` call will be loaded
                    - registry: the model will be downloaded from the Lightning Model Registry with following notations:

                        - ``'registry'``: uses the latest/default version of default model set
                          with ``Tainer(..., model_registry="my-model")``
                        - ``'registry:model-name'``: uses the latest/default version of this model `model-name`
                        - ``'registry:model-name:version:v2'``: uses the specific version 'v2' of the model `model-name`
                        - ``'registry:version:v2'``: uses the default model set
                          with ``Tainer(..., model_registry="my-model")`` and version 'v2'


        Raises:
            TypeError:
                If ``model`` is not :class:`~lightning.pytorch.core.LightningModule` for torch version less than
                2.0.0 and if ``model`` is not :class:`~lightning.pytorch.core.LightningModule` or
                :class:`torch._dynamo.OptimizedModule` for torch versions greater than or equal to 2.0.0 .

        For more information about multiple dataloaders, see this :ref:`section <multiple-dataloaders>`.

        
src/lightning/pytorch/trainer/trainer.py