def _generate_train_idx(target, steps_ahead_start, steps_ahead_end) -> SupportedIndex:
    """The returned index depends on the following cases:

    case 1
        (steps_ahead_start >= 0 and steps_ahead_end is None or <= 1)
        the complete index is within the target index; always True for all models except SKLearnModels.
    case 2
        steps_ahead_start < 0: add indices before the target start time; only possible for SKLearnModels
        where the minimum past lag is larger than input_chunk_length.
    case 3
        steps_ahead_end > 0: add indices after the target end time; only possible for SKLearnModels
        where the maximum future lag is larger than output_chunk_length.

    Parameters
    ----------
    target
        the target series.
    steps_ahead_start
        how many steps ahead of target start time to begin the index.
    steps_ahead_end
        how many steps ahead of target end time to end the index.
    """
    # case 1
    if steps_ahead_start >= 0 and (steps_ahead_end is None or steps_ahead_end <= -1):
        return target.time_index[steps_ahead_start:steps_ahead_end]

    # case 2
    idx_start = (
        generate_index(
            end=target.start_time() - target.freq,
            length=abs(steps_ahead_start),
            freq=target.freq,
        )
        if steps_ahead_start < 0
        else target.time_index.__class__([])
    )

    # if `steps_ahead_start >= 0` or `steps_ahead_end <= 0` we must extract a slice of the target series index
    center_start = steps_ahead_start if steps_ahead_start >= 0 else None
    center_end = (
        steps_ahead_end
        if steps_ahead_end is not None and steps_ahead_end <= 0
        else None
    )
    idx_center = target.time_index[center_start:center_end]

    # case 3
    idx_end = (
        generate_index(
            start=target.end_time() + target.freq,
            length=abs(steps_ahead_end),
            freq=target.freq,
        )
        if steps_ahead_end is not None and steps_ahead_end > 0
        else target.time_index.__class__([])
    )

    # concatenate start, center, and end index
    # note: pandas' union() returns type pd.Index(), so we construct index directly from index class
    return target.time_index.__class__(idx_start.union(idx_center).union(idx_end))
The returned index depends on the following cases:

    case 1
        (steps_ahead_start >= 0 and steps_ahead_end is None or <= 1)
        the complete index is within the target index; always True for all models except SKLearnModels.
    case 2
        steps_ahead_start < 0: add indices before the target start time; only possible for SKLearnModels
        where the minimum past lag is larger than input_chunk_length.
    case 3
        steps_ahead_end > 0: add indices after the target end time; only possible for SKLearnModels
        where the maximum future lag is larger than output_chunk_length.

    Parameters
    ----------
    target
        the target series.
    steps_ahead_start
        how many steps ahead of target start time to begin the index.
    steps_ahead_end
        how many steps ahead of target end time to end the index.
    
darts/dataprocessing/encoders/encoder_base.py