def test_sample_weight_global(self, config):
        """Check sample weights for ensemble models with global forecasting models.

        NaiveEnsembleModel
            Sample weights will only be passed to global forecasting models.
            A weighted linear model that ignores `1000` should learn that y_t = y_(t-1) + 1. When calling predict():
            - linear model should predict y_(t,lin) = 1000 + 1 = 1001

            The ensemble takes the average:
            - y_t = 0.5 * y_(t,lin) + 0.5 * y_(t,lin) = 1001 + 1001 = 1001

        RegressionEnsembleModel
            Sample weights will be passed to global forecasting models and regression ensemble model.
            A weighted linear model that ignores `1000` should learn that y_t = y_(t-1) + 1. When calling predict():
            - linear model should predict y_(t,lin) = y_(t-1) + 1

            The training set for regression ensemble covers the forecasts for and labels of last 5 points, where labels
            10000 and 1002 are ignored (0 weight):
            - the linear forecasting model generates forecasts: [1001, 1002, 1003, 1004, 1005]

            The ensemble model should then learn a perfect fit based on the output of the linear model:
            - y_t = 1.0 * y_(t,lin) + 0.0 * y_(t,ns) = 1.0 * (y_(t-1) + 1)
        """
        model_cls, single_series = config
        if issubclass(model_cls, NaiveEnsembleModel):
            series = TimeSeries.from_values(np.array([0.0, 1.0, 2.0, 3.0, 1000]))
            weights = TimeSeries.from_values(np.array([1.0, 1.0, 1.0, 1.0, 0.0]))
            pred_expected = np.array([[1001.0]])
            kwargs = {}
        else:
            series = TimeSeries.from_values(
                np.array([0.0, 1.0, 2.0, 3.0, 4.0, 1000, 10000, 1002, 1003, 1004, 1005])
            )
            weights = TimeSeries.from_values(
                np.array([1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0])
            )
            pred_expected = np.array([[1006.0]])
            kwargs = {"regression_train_n_points": 5}

        if not single_series:
            series = [series] * 2
            weights = [weights] * 2

        model = model_cls(
            [LinearRegressionModel(lags=[-1]), LinearRegressionModel(lags=[-1])],
            **kwargs,
        )
        model.fit(series, sample_weight=weights)
        preds_weighted = model.predict(n=1, series=series)
        if single_series:
            preds_weighted = [preds_weighted]

        for preds in preds_weighted:
            np.testing.assert_array_almost_equal(preds.values(), pred_expected)

        # make sure that without weights we get different results
        model = model_cls(
            [LinearRegressionModel(lags=[-1]), LinearRegressionModel(lags=[-1])],
            **kwargs,
        )
        model.fit(series)
        preds = model.predict(n=1, series=series)
        if single_series:
            preds = [preds]

        for pred_w, pred_nw in zip(preds_weighted, preds):
            with pytest.raises(AssertionError):
                np.testing.assert_array_almost_equal(pred_w.values(), pred_nw.values())
Check sample weights for ensemble models with global forecasting models.

        NaiveEnsembleModel
            Sample weights will only be passed to global forecasting models.
            A weighted linear model that ignores `1000` should learn that y_t = y_(t-1) + 1. When calling predict():
            - linear model should predict y_(t,lin) = 1000 + 1 = 1001

            The ensemble takes the average:
            - y_t = 0.5 * y_(t,lin) + 0.5 * y_(t,lin) = 1001 + 1001 = 1001

        RegressionEnsembleModel
            Sample weights will be passed to global forecasting models and regression ensemble model.
            A weighted linear model that ignores `1000` should learn that y_t = y_(t-1) + 1. When calling predict():
            - linear model should predict y_(t,lin) = y_(t-1) + 1

            The training set for regression ensemble covers the forecasts for and labels of last 5 points, where labels
            10000 and 1002 are ignored (0 weight):
            - the linear forecasting model generates forecasts: [1001, 1002, 1003, 1004, 1005]

            The ensemble model should then learn a perfect fit based on the output of the linear model:
            - y_t = 1.0 * y_(t,lin) + 0.0 * y_(t,ns) = 1.0 * (y_(t-1) + 1)
        
darts/tests/models/forecasting/test_ensemble_models.py