def _get_start_index(
    series: TimeSeries,
    series_idx: int,
    start: Union[pd.Timestamp, int, float],
    start_format: Literal["value", "position"],
    stride: int,
    historical_forecasts_time_index: Optional[TimeIndex] = None,
):
    """Finds a valid historical forecast start point within either `series` or `historical_forecasts_time_index`
    (depending on whether `historical_forecasts_time_index` is passed, denoted as `ref`).

    - If `start` is larger or equal to the first index of `ref`, uses `start` directly.
    - If `start` is before the first index of `ref`, tries to find a start point within `ref` that lies a
      round-multiple `stride` time steps ahead of `start`.

    Raises an error if the new start index from above is larger than the last index in `ref`.

    Parameters
    ----------
    series
        A time series. If `historical_forecasts_time_index` is `None`, will use this series' time index as a reference
        index.
    series_idx
        The sequence index of the `series`.
    start
        The start point for historical forecasts.
    start_format
        The start format for historical forecasts.
    stride
        The stride for historical forecasts.
    historical_forecasts_time_index
        Optionally, the historical forecast index (or the boundaries only) to use as the reference index.
    """
    series_start, series_end = series._time_index[0], series._time_index[-1]
    has_dti = series._has_datetime_index
    # find start position relative to the series start time
    if isinstance(start, float):
        # fraction of series
        rel_start = series.get_index_at_point(start)
    elif start_format == "value" and not (isinstance(start, int) and has_dti):
        # start is a time stamp for DatetimeIndex, and integer for RangeIndex
        rel_start = n_steps_between(start, series_start, freq=series.freq)
    else:
        # start is a positional index
        start: int
        rel_start = start if start >= 0 else len(series) - abs(start)

    # find actual start time
    start_idx = _adjust_start(rel_start, stride)
    _check_start(
        series=series,
        start_idx=start_idx,
        start=start,
        start_format=start_format,
        series_start=series_start,
        ref_start=series_start,
        ref_end=series_end,
        stride=stride,
        series_idx=series_idx,
        is_historical_forecast=False,
    )
    if historical_forecasts_time_index is not None:
        hfc_start, hfc_end = (
            historical_forecasts_time_index[0],
            historical_forecasts_time_index[-1],
        )
        # at this point, we know that `start_idx` is within `series`. Now, find the position of that time step
        # relative to the first forecastable point
        rel_start_hfc = n_steps_between(
            series._time_index[start_idx], hfc_start, freq=series.freq
        )
        # get the positional index of `hfc_start` in `series`
        hfc_start_idx = start_idx - rel_start_hfc
        # potentially, adjust the position to be inside the forecastable points
        hfc_start_idx += _adjust_start(rel_start_hfc, stride)
        _check_start(
            series=series,
            start_idx=hfc_start_idx,
            start=start,
            start_format=start_format,
            series_start=series_start,
            ref_start=hfc_start,
            ref_end=hfc_end,
            stride=stride,
            series_idx=series_idx,
            is_historical_forecast=True,
        )
        start_idx = hfc_start_idx
    return start_idx, rel_start
Finds a valid historical forecast start point within either `series` or `historical_forecasts_time_index`
    (depending on whether `historical_forecasts_time_index` is passed, denoted as `ref`).

    - If `start` is larger or equal to the first index of `ref`, uses `start` directly.
    - If `start` is before the first index of `ref`, tries to find a start point within `ref` that lies a
      round-multiple `stride` time steps ahead of `start`.

    Raises an error if the new start index from above is larger than the last index in `ref`.

    Parameters
    ----------
    series
        A time series. If `historical_forecasts_time_index` is `None`, will use this series' time index as a reference
        index.
    series_idx
        The sequence index of the `series`.
    start
        The start point for historical forecasts.
    start_format
        The start format for historical forecasts.
    stride
        The stride for historical forecasts.
    historical_forecasts_time_index
        Optionally, the historical forecast index (or the boundaries only) to use as the reference index.
    
darts/utils/historical_forecasts/utils.py