def _historical_forecasts_sanitize_kwargs(
    model,
    fit_kwargs: Optional[dict[str, Any]],
    predict_kwargs: Optional[dict[str, Any]],
    retrain: bool,
    show_warnings: bool,
) -> tuple[dict[str, Any], dict[str, Any]]:
    """Convert kwargs to dictionary, check that their content is compatible with called methods."""
    hfc_args = set(inspect.signature(model.historical_forecasts).parameters)
    # replace `forecast_horizon` with `n`
    hfc_args = hfc_args - {"forecast_horizon"}
    hfc_args = hfc_args.union({"n"})

    if fit_kwargs is None:
        fit_kwargs = dict()
    elif retrain:
        fit_kwargs = _historical_forecasts_check_kwargs(
            hfc_args=hfc_args,
            name_kwargs="fit_kwargs",
            dict_kwargs=fit_kwargs,
        )
    elif show_warnings:
        logger.warning(
            "`fit_kwargs` was provided with `retrain=False`, the argument will be ignored."
        )

    if predict_kwargs is None:
        predict_kwargs = dict()
    else:
        predict_kwargs = _historical_forecasts_check_kwargs(
            hfc_args=hfc_args,
            name_kwargs="predict_kwargs",
            dict_kwargs=predict_kwargs,
        )
    return fit_kwargs, predict_kwargs
Convert kwargs to dictionary, check that their content is compatible with called methods.
darts/utils/historical_forecasts/utils.py