code: 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
  
imports: from types import SimpleNamespace
  from typing import Any, Callable, Dict, Optional, Sequence, Set, Tuple, Union
  import inspect
  import numpy
  import pandas
  from numpy.typing import ArrayLike
  from darts.logging import get_logger, raise_if_not, raise_log
  from darts.timeseries import TimeSeries
  from darts.utils.timeseries_generation import generate_index
  from darts.utils.utils import series2seq
label_desc: Use image node_id 2 for calling a global function with example usage: _historical_forecasts_sanitize_kwargs(model, fit_kwargs, predict_kwargs, retrain, show_warnings) and returns: fit_kwargs,  predict_kwargs