def get_feature_times(
        target: TimeSeries,
        past: TimeSeries,
        future: TimeSeries,
        lags: Optional[int],
        lags_past: Optional[int],
        lags_future: Optional[int],
        max_samples_per_ts: Optional[int],
    ) -> pd.Index:
        """
        Helper function that returns the times shared by all of the specified series that can be used
        to create features and labels. This is performed by using the helper functions
        `get_feature_times_target_or_past` and `get_feature_times_future` (both defined below) to extract
        the feature times from the target series, past covariates, and future covariates respectively, and
        then intersecting these features times with one another. A series is considered to be 'specified'
        if its corresponding lag (e.g. `lags` for `target`, or `lags_future` for `future`) is not `None`.
        If requested, the last `max_samples_per_ts` times are taken.

        This function is basically a simplified implementation of `get_feature_times` in `tabularization.py`
        that only works for `is_training = False`.
        """
        # `times` is initialized inside loop:
        times = None
        all_series = [target, past, future]
        all_lags = [lags, lags_past, lags_future]
        for i, (series_i, lags_i) in enumerate(zip(all_series, all_lags)):
            # If `lags` not specified, ignore series:
            lags_specified = lags_i is not None
            is_target_or_past = i < 2
            if lags_specified:
                if is_target_or_past:
                    times_i = (
                        TestCreateLaggedPredictionData.get_feature_times_target_or_past(
                            series_i, lags_i
                        )
                    )
                else:
                    times_i = TestCreateLaggedPredictionData.get_feature_times_future(
                        series_i, lags_i
                    )
            else:
                times_i = None
            if times_i is not None:
                # Initialise `times` if this is first specified series:
                if times is None:
                    times = times_i
                # Intersect `times` with `times_i` if `times` already initialized:
                else:
                    times = times.intersection(times_i)
        # Take most recent `max_samples_per_ts` samples if requested:
        if (max_samples_per_ts is not None) and (len(times) > max_samples_per_ts):
            times = times[-max_samples_per_ts:]
        return times

        Helper function that returns the times shared by all of the specified series that can be used
        to create features and labels. This is performed by using the helper functions
        `get_feature_times_target_or_past` and `get_feature_times_future` (both defined below) to extract
        the feature times from the target series, past covariates, and future covariates respectively, and
        then intersecting these features times with one another. A series is considered to be 'specified'
        if its corresponding lag (e.g. `lags` for `target`, or `lags_future` for `future`) is not `None`.
        If requested, the last `max_samples_per_ts` times are taken.

        This function is basically a simplified implementation of `get_feature_times` in `tabularization.py`
        that only works for `is_training = False`.
        
darts/tests/utils/tabularization/test_create_lagged_prediction_data.py