def test_metric_kwargs(self):
        """Tests residuals with different metric_kwargs based on historical forecasts generated on a sequence
        `series` with last_points_only=False"""
        y = lt(length=20)
        y = y.stack(y + 1.0)
        hfc = lt(length=10, start=y.start_time() + 10 * y.freq)
        hfc = hfc.stack(hfc + 1.0)
        y = [y, y]
        hfc = [[hfc, hfc], [hfc]]

        model = NaiveDrift()
        # reduction `metric_kwargs` are bypassed, n_jobs not
        bts = model.residuals(
            series=y,
            historical_forecasts=hfc,
            metric=metrics.ae,
            last_points_only=False,
            metric_kwargs={
                "component_reduction": np.median,
                "time_reduction": np.mean,
                "n_jobs": -1,
            },
            values_only=True,
        )
        assert isinstance(bts, list) and len(bts) == 2

        # `ae` with time and component reduction is equal to `mae` with component reduction
        bt_expected = metrics.ae(
            y[0],
            hfc[0][0],
            series_reduction=None,
            time_reduction=None,
            component_reduction=None,
        )[:, :, None]
        for bt_list in bts:
            for bt in bt_list:
                np.testing.assert_array_almost_equal(bt, bt_expected)
Tests residuals with different metric_kwargs based on historical forecasts generated on a sequence
        `series` with last_points_only=False
darts/tests/models/forecasting/test_residuals.py