def generate_train_inference_idx(
        self, n: int, target: TimeSeries, covariates: Optional[TimeSeries] = None
    ) -> tuple[SupportedIndex, pd.Timestamp]:
        """
        Generates/extracts time index (or integer index) for covariates for training and inference / prediction.

        Parameters
        ----------
        n
            The forecasting horizon.
        target
            The target TimeSeries used for training and inference / prediction as `series`.
        covariates
            Optionally, the covariates used for training and inference / prediction.
            If given, the returned time index is equal to the `covariates` time index. Else, the returned time index
            covers the minimum required covariate time spans for performing training and inference / prediction with a
            specific forecasting model. These requirements are derived from parameters set at
            :class:`CovariatesIndexGenerator` creation.
        """
        train_idx, target_end = self.generate_train_idx(
            target=target, covariates=covariates
        )
        inference_idx, _ = self.generate_inference_idx(
            n=n, target=target, covariates=covariates
        )
        # generate index end is inclusive, should not be a problem when taking union
        gap = generate_index(
            start=train_idx[-1], end=inference_idx[0] - target.freq, freq=target.freq
        )
        return (
            train_idx.__class__.union(train_idx, gap).union(inference_idx),
            target_end,
        )

        Generates/extracts time index (or integer index) for covariates for training and inference / prediction.

        Parameters
        ----------
        n
            The forecasting horizon.
        target
            The target TimeSeries used for training and inference / prediction as `series`.
        covariates
            Optionally, the covariates used for training and inference / prediction.
            If given, the returned time index is equal to the `covariates` time index. Else, the returned time index
            covers the minimum required covariate time spans for performing training and inference / prediction with a
            specific forecasting model. These requirements are derived from parameters set at
            :class:`CovariatesIndexGenerator` creation.
        
darts/dataprocessing/encoders/encoder_base.py