def load_from_checkpoint(
        cls,
        checkpoint_path: Union[_PATH, IO],
        map_location: _MAP_LOCATION_TYPE = None,
        hparams_file: Optional[_PATH] = None,
        strict: Optional[bool] = None,
        **kwargs: Any,
    ) -> Self:
        r"""Primary way of loading a model from a checkpoint. When Lightning saves a checkpoint it stores the arguments
        passed to ``__init__``  in the checkpoint under ``"hyper_parameters"``.

        Any arguments specified through \*\*kwargs will override args stored in ``"hyper_parameters"``.

        Args:
            checkpoint_path: Path to checkpoint. This can also be a URL, or file-like object
            map_location:
                If your checkpoint saved a GPU model and you now load on CPUs
                or a different number of GPUs, use this to map to the new setup.
                The behaviour is the same as in :func:`torch.load`.
            hparams_file: Optional path to a ``.yaml`` or ``.csv`` file with hierarchical structure
                as in this example::

                    drop_prob: 0.2
                    dataloader:
                        batch_size: 32

                You most likely won't need this since Lightning will always save the hyperparameters
                to the checkpoint.
                However, if your checkpoint weights don't have the hyperparameters saved,
                use this method to pass in a ``.yaml`` file with the hparams you'd like to use.
                These will be converted into a :class:`~dict` and passed into your
                :class:`LightningModule` for use.

                If your model's ``hparams`` argument is :class:`~argparse.Namespace`
                and ``.yaml`` file has hierarchical structure, you need to refactor your model to treat
                ``hparams`` as :class:`~dict`.
            strict: Whether to strictly enforce that the keys in :attr:`checkpoint_path` match the keys
                returned by this module's state dict. Defaults to ``True`` unless ``LightningModule.strict_loading`` is
                set, in which case it defaults to the value of ``LightningModule.strict_loading``.
            \**kwargs: Any extra keyword args needed to init the model. Can also be used to override saved
                hyperparameter values.

        Return:
            :class:`LightningModule` instance with loaded weights and hyperparameters (if available).

        Note:
            ``load_from_checkpoint`` is a **class** method. You should use your :class:`LightningModule`
            **class** to call it instead of the :class:`LightningModule` instance, or a
            ``TypeError`` will be raised.

        Note:
            To ensure all layers can be loaded from the checkpoint, this function will call
            :meth:`~lightning.pytorch.core.hooks.ModelHooks.configure_model` directly after instantiating the
            model if this hook is overridden in your LightningModule. However, note that ``load_from_checkpoint`` does
            not support loading sharded checkpoints, and you may run out of memory if the model is too large. In this
            case, consider loading through the Trainer via ``.fit(ckpt_path=...)``.

        Example::

            # load weights without mapping ...
            model = MyLightningModule.load_from_checkpoint('path/to/checkpoint.ckpt')

            # or load weights mapping all weights from GPU 1 to GPU 0 ...
            map_location = {'cuda:1':'cuda:0'}
            model = MyLightningModule.load_from_checkpoint(
                'path/to/checkpoint.ckpt',
                map_location=map_location
            )

            # or load weights and hyperparameters from separate files.
            model = MyLightningModule.load_from_checkpoint(
                'path/to/checkpoint.ckpt',
                hparams_file='/path/to/hparams_file.yaml'
            )

            # override some of the params with new values
            model = MyLightningModule.load_from_checkpoint(
                PATH,
                num_layers=128,
                pretrained_ckpt_path=NEW_PATH,
            )

            # predict
            pretrained_model.eval()
            pretrained_model.freeze()
            y_hat = pretrained_model(x)

        """
        loaded = _load_from_checkpoint(
            cls,
            checkpoint_path,
            map_location,
            hparams_file,
            strict,
            **kwargs,
        )
        return cast(Self, loaded)
Primary way of loading a model from a checkpoint. When Lightning saves a checkpoint it stores the arguments
        passed to ``__init__``  in the checkpoint under ``"hyper_parameters"``.

        Any arguments specified through \*\*kwargs will override args stored in ``"hyper_parameters"``.

        Args:
            checkpoint_path: Path to checkpoint. This can also be a URL, or file-like object
            map_location:
                If your checkpoint saved a GPU model and you now load on CPUs
                or a different number of GPUs, use this to map to the new setup.
                The behaviour is the same as in :func:`torch.load`.
            hparams_file: Optional path to a ``.yaml`` or ``.csv`` file with hierarchical structure
                as in this example::

                    drop_prob: 0.2
                    dataloader:
                        batch_size: 32

                You most likely won't need this since Lightning will always save the hyperparameters
                to the checkpoint.
                However, if your checkpoint weights don't have the hyperparameters saved,
                use this method to pass in a ``.yaml`` file with the hparams you'd like to use.
                These will be converted into a :class:`~dict` and passed into your
                :class:`LightningModule` for use.

                If your model's ``hparams`` argument is :class:`~argparse.Namespace`
                and ``.yaml`` file has hierarchical structure, you need to refactor your model to treat
                ``hparams`` as :class:`~dict`.
            strict: Whether to strictly enforce that the keys in :attr:`checkpoint_path` match the keys
                returned by this module's state dict. Defaults to ``True`` unless ``LightningModule.strict_loading`` is
                set, in which case it defaults to the value of ``LightningModule.strict_loading``.
            \**kwargs: Any extra keyword args needed to init the model. Can also be used to override saved
                hyperparameter values.

        Return:
            :class:`LightningModule` instance with loaded weights and hyperparameters (if available).

        Note:
            ``load_from_checkpoint`` is a **class** method. You should use your :class:`LightningModule`
            **class** to call it instead of the :class:`LightningModule` instance, or a
            ``TypeError`` will be raised.

        Note:
            To ensure all layers can be loaded from the checkpoint, this function will call
            :meth:`~lightning.pytorch.core.hooks.ModelHooks.configure_model` directly after instantiating the
            model if this hook is overridden in your LightningModule. However, note that ``load_from_checkpoint`` does
            not support loading sharded checkpoints, and you may run out of memory if the model is too large. In this
            case, consider loading through the Trainer via ``.fit(ckpt_path=...)``.

        Example::

            # load weights without mapping ...
            model = MyLightningModule.load_from_checkpoint('path/to/checkpoint.ckpt')

            # or load weights mapping all weights from GPU 1 to GPU 0 ...
            map_location = {'cuda:1':'cuda:0'}
            model = MyLightningModule.load_from_checkpoint(
                'path/to/checkpoint.ckpt',
                map_location=map_location
            )

            # or load weights and hyperparameters from separate files.
            model = MyLightningModule.load_from_checkpoint(
                'path/to/checkpoint.ckpt',
                hparams_file='/path/to/hparams_file.yaml'
            )

            # override some of the params with new values
            model = MyLightningModule.load_from_checkpoint(
                PATH,
                num_layers=128,
                pretrained_ckpt_path=NEW_PATH,
            )

            # predict
            pretrained_model.eval()
            pretrained_model.freeze()
            y_hat = pretrained_model(x)

        
src/lightning/pytorch/core/module.py