def test_historical_forecasts_with_scaler(self, params):
        """Apply manually the scaler on the target and covariates to compare with automatic scaling for both
        optimized and un-optimized historical forecasts
        """

        (ts, hf_scaler), retrain, last_points_only, model_cls = params
        ocl = 6
        model_params = self.helper_get_model_params(model_cls, ts, ocl)
        model = model_cls(**model_params)

        # local models do not support historical forecast with retrain=False
        if isinstance(model, LocalForecastingModel) and not retrain:
            return
        # skip test when model does not support the covariate
        if ("past_covariates" in ts and not model.supports_past_covariates) or (
            "future_covariates" in ts and not model.supports_future_covariates
        ):
            return

        # pre-train on the entire unscaled target, overfitting/accuracy is not important
        if not retrain:
            model.fit(**ts)
            for ts_name in hf_scaler.keys():
                hf_scaler[ts_name].fit(ts[ts_name])

        hf_args = {
            "start": -ocl - 1,  # in order to get 2 forecasts since stride=1
            "start_format": "position",
            "forecast_horizon": ocl,
            "stride": 1,
            "retrain": retrain,
            "overlap_end": False,
            "last_points_only": last_points_only,
            "verbose": False,
            "enable_optimization": False,
        }
        # un-transformed series, scaler applied within the method
        hf_auto = model.historical_forecasts(
            **ts,
            **hf_args,
            data_transformers=hf_scaler,
        )

        hf_auto_pipeline = model.historical_forecasts(
            **ts,
            **hf_args,
            data_transformers={
                key_: Pipeline([val_]) for key_, val_ in hf_scaler.items()
            },
        )

        # verify that the results are identical when using single Scaler or a Pipeline
        assert len(hf_auto) == len(hf_auto_pipeline) == 2
        self.helper_compare_hf(hf_auto, hf_auto_pipeline)

        # optimized historical forecast since horizon_length <= ocl and retrain=False
        if not retrain:
            opti_hf_args = {**hf_args, **{"enable_optimization": True}}
            assert opti_hf_args["enable_optimization"]

            opti_hf_auto = model.historical_forecasts(
                **ts,
                **opti_hf_args,
                data_transformers=hf_scaler,
            )
            assert len(opti_hf_auto) == len(hf_auto) == 2
            self.helper_compare_hf(hf_auto, opti_hf_auto)

        # for 2nd to last historical forecast
        manual_hf_0 = self.helper_manual_scaling_prediction(
            model, ts, hf_scaler, retrain, -ocl - 1, ocl
        )
        # for last historical forecast
        manual_hf_1 = self.helper_manual_scaling_prediction(
            model, ts, hf_scaler, retrain, -ocl, ocl
        )

        # verify that automatic and manual pre-scaling produce identical forecasts
        if last_points_only:
            tmp_ts = TimeSeries.from_times_and_values(
                times=manual_hf_1.time_index[-2:],
                values=np.array([manual_hf_0.values()[-1], manual_hf_1.values()[-1]]),
                columns=manual_hf_0.components,
            )
            self.helper_compare_hf(tmp_ts, hf_auto)
        else:
            self.helper_compare_hf(hf_auto, [manual_hf_0, manual_hf_1])
Apply manually the scaler on the target and covariates to compare with automatic scaling for both
        optimized and un-optimized historical forecasts
        
darts/tests/utils/historical_forecasts/test_historical_forecasts.py