def test_fit_kwargs(self, model_type, enable_optimization):
        """check that the parameters provided in fit_kwargs are correctly processed"""
        valid_fit_kwargs = {"max_samples_per_ts": 3}
        invalid_fit_kwargs = {"series": self.ts_pass_train}
        unsupported_fit_kwargs = {"unsupported": "unsupported"}

        n = 2
        model = self.create_model(1, use_ll=False, model_type=model_type)

        # torch not available
        if model is None:
            return

        model.fit(series=self.ts_pass_train[:-n])

        # supported argument
        hist_fc = model.historical_forecasts(
            self.ts_pass_train,
            forecast_horizon=1,
            num_samples=1,
            start=len(self.ts_pass_train) - n,
            retrain=True,
            enable_optimization=enable_optimization,
            fit_kwargs=valid_fit_kwargs,
        )

        assert hist_fc.components.equals(self.ts_pass_train.components)
        assert len(hist_fc) == n

        # passing unsupported argument
        with pytest.raises(TypeError):
            hist_fc = model.historical_forecasts(
                self.ts_pass_train,
                forecast_horizon=1,
                start=len(self.ts_pass_train) - n,
                retrain=True,
                enable_optimization=enable_optimization,
                fit_kwargs=unsupported_fit_kwargs,
            )

        # passing hist_fc parameters in fit_kwargs, with retrain=False
        hist_fc = model.historical_forecasts(
            self.ts_pass_train,
            forecast_horizon=1,
            start=len(self.ts_pass_train) - n,
            retrain=False,
            enable_optimization=enable_optimization,
            fit_kwargs=invalid_fit_kwargs,
        )

        assert hist_fc.components.equals(self.ts_pass_train.components)
        assert len(hist_fc) == n

        # passing hist_fc parameters in fit_kwargs, interfering with the logic
        with pytest.raises(ValueError) as msg:
            model.historical_forecasts(
                self.ts_pass_train,
                forecast_horizon=1,
                start=len(self.ts_pass_train) - n,
                retrain=True,
                enable_optimization=enable_optimization,
                fit_kwargs=invalid_fit_kwargs,
            )
        assert str(msg.value).startswith(
            "The following parameters cannot be passed in `fit_kwargs`"
        )
check that the parameters provided in fit_kwargs are correctly processed
darts/tests/utils/historical_forecasts/test_historical_forecasts.py