def test_output_shift(self, config):
        """Tests shifted output for shift smaller than, equal to, and larger than output_chunk_length.
        RNNModel does not support shift output chunk.
        """
        np.random.seed(0)
        (model_cls, model_kwargs), shift = config
        if issubclass(model_cls, RNNModel):
            return

        model_kwargs = copy.deepcopy(model_kwargs)
        model_kwargs.pop("input_chunk_length")
        model_kwargs.pop("output_chunk_length")

        if issubclass(model_cls, TFTModel):
            model_kwargs.update({"likelihood": None, "loss_fn": torch.nn.MSELoss()})

        icl = 8
        ocl = 7
        series = tg.gaussian_timeseries(
            length=28, start=pd.Timestamp("2000-01-01"), freq="d"
        )

        model = self.helper_create_torch_model(
            model_cls, icl, ocl, shift, **model_kwargs
        )
        model.fit(series)

        # no auto-regression with shifted output
        with pytest.raises(ValueError) as err:
            _ = model.predict(n=ocl + 1)
        assert str(err.value).startswith("Cannot perform auto-regression")

        # pred starts with a shift
        for ocl_test in [ocl - 1, ocl]:
            pred = model.predict(n=ocl_test)
            assert pred.start_time() == series.end_time() + (shift + 1) * series.freq
            assert len(pred) == ocl_test
            assert pred.freq == series.freq

        # check that shifted output chunk results with encoders are the
        # same as using identical covariates

        # model trained on encoders
        cov_support = []
        covs = {}
        if model.supports_past_covariates:
            cov_support.append("past")
            covs["past_covariates"] = tg.datetime_attribute_timeseries(
                series,
                attribute="dayofweek",
                add_length=0,
            )
        if model.supports_future_covariates:
            cov_support.append("future")
            covs["future_covariates"] = tg.datetime_attribute_timeseries(
                series,
                attribute="dayofweek",
                add_length=ocl + shift,
            )

        if not cov_support:
            return

        add_encoders = {
            "datetime_attribute": {cov: ["dayofweek"] for cov in cov_support}
        }
        model_enc_shift = self.helper_create_torch_model(
            model_cls, icl, ocl, shift, add_encoders=add_encoders, **model_kwargs
        )
        model_enc_shift.fit(series)

        # model trained with identical covariates
        model_fc_shift = self.helper_create_torch_model(
            model_cls, icl, ocl, shift, **model_kwargs
        )

        model_fc_shift.fit(series, **covs)

        pred_enc = model_enc_shift.predict(n=ocl)
        pred_fc = model_fc_shift.predict(n=ocl)
        assert pred_enc == pred_fc

        # check that historical forecasts works properly
        hist_fc_start = -(ocl + shift)
        pred_last_hist_fc = model_fc_shift.predict(n=ocl, series=series[:hist_fc_start])
        # non-optimized hist fc
        hist_fc = model_fc_shift.historical_forecasts(
            series=series,
            start=hist_fc_start,
            start_format="position",
            retrain=False,
            forecast_horizon=ocl,
            last_points_only=False,
            enable_optimization=False,
            **covs,
        )
        assert len(hist_fc) == 1
        assert hist_fc[0] == pred_last_hist_fc
        # optimized hist fc, due to batch predictions, slight deviations in values
        hist_fc_opt = model_fc_shift.historical_forecasts(
            series=series,
            start=hist_fc_start,
            start_format="position",
            retrain=False,
            forecast_horizon=ocl,
            last_points_only=False,
            enable_optimization=True,
            **covs,
        )
        assert len(hist_fc_opt) == 1
        assert hist_fc_opt[0].time_index.equals(pred_last_hist_fc.time_index)
        np.testing.assert_array_almost_equal(
            hist_fc_opt[0].values(copy=False), pred_last_hist_fc.values(copy=False)
        )

        # covs too short
        for cov_name in cov_support:
            with pytest.raises(ValueError) as err:
                add_covs = {
                    cov_name + "_covariates": covs[cov_name + "_covariates"][:-1]
                }
                _ = model_fc_shift.predict(n=ocl, **add_covs)
            assert f"provided `{cov_name}_covariates` at series sequence index" in str(
                err.value
            )
Tests shifted output for shift smaller than, equal to, and larger than output_chunk_length.
        RNNModel does not support shift output chunk.
        
darts/tests/models/forecasting/test_torch_forecasting_model.py