def _convert_loaded_hparams(
    model_args: dict[str, Any], hparams_type: Optional[Union[Callable, str]] = None
) -> dict[str, Any]:
    """Convert hparams according given type in callable or string (past) format."""
    # if not hparams type define
    if not hparams_type:
        return model_args
    # if past checkpoint loaded, convert str to callable
    if isinstance(hparams_type, str):
        hparams_type = AttributeDict
    # convert hparams
    return hparams_type(model_args)
Convert hparams according given type in callable or string (past) format.
src/lightning/pytorch/core/saving.py