code: def _get_historical_forecast_boundaries(
      model,
      series: TimeSeries,
      series_idx: int,
      past_covariates: Optional[TimeSeries],
      future_covariates: Optional[TimeSeries],
      start: Optional[Union[pd.Timestamp, float, int]],
      start_format: Literal["position", "value"],
      forecast_horizon: int,
      overlap_end: bool,
      freq: pd.DateOffset,
      show_warnings: bool = True,
  ) -> Tuple[Any, ...]:
      """
      Based on the boundaries of the forecastable time index, generates the boundaries of each covariates using the lags.
  
      For TimeSeries with a RangeIndex, the boundaries are converted to positional indexes to slice the array
      appropriately when start > 0.
  
      When applicable, move the start boundaries to the value provided by the user.
      """
      # obtain forecastable indexes boundaries, as values from the time index
      historical_forecasts_time_index = (
          _get_historical_forecast_predict_index(
              model,
              series,
              series_idx,
              past_covariates,
              future_covariates,
              forecast_horizon,
              overlap_end,
          )
      )
  
      # adjust boundaries based on start, forecast_horizon and overlap_end
      historical_forecasts_time_index = _adjust_historical_forecasts_time_index(
          series=series,
          series_idx=series_idx,
          historical_forecasts_time_index=historical_forecasts_time_index,
          start=start,
          start_format=start_format,
          show_warnings=show_warnings,
      )
  
      # re-adjust the slicing indexes to account for the lags
      (
          min_target_lag,
          _,
          min_past_cov_lag,
          max_past_cov_lag,
          min_future_cov_lag,
          max_future_cov_lag,
      ) = model.extreme_lags
  
      # target lags are <= 0
      (
          hist_fct_tgt_start,
          hist_fct_tgt_end,
      ) = historical_forecasts_time_index
      if min_target_lag is not None:
          hist_fct_tgt_start += min_target_lag * freq
      hist_fct_tgt_end -= 1 * freq
      # past lags are <= 0
      (
          hist_fct_pc_start,
          hist_fct_pc_end,
      ) = historical_forecasts_time_index
      if min_past_cov_lag is not None:
          hist_fct_pc_start += min_past_cov_lag * freq
      if max_past_cov_lag is not None:
          hist_fct_pc_end += max_past_cov_lag * freq
      # future lags can be anything
      (
          hist_fct_fc_start,
          hist_fct_fc_end,
      ) = historical_forecasts_time_index
      if min_future_cov_lag is not None:
          hist_fct_fc_start += min_future_cov_lag * freq
      if max_future_cov_lag is not None:
          hist_fct_fc_end += max_future_cov_lag * freq
  
      # convert actual integer index values (points) to positional index, make end bound inclusive
      if series.has_range_index:
          hist_fct_tgt_start = series.get_index_at_point(
              hist_fct_tgt_start
          )
          hist_fct_tgt_end = (
              series.get_index_at_point(hist_fct_tgt_end) + 1
          )
          if past_covariates is not None:
              hist_fct_pc_start = past_covariates.get_index_at_point(
                  hist_fct_pc_start
              )
              hist_fct_pc_end = (
                  past_covariates.get_index_at_point(hist_fct_pc_end)
                  + 1
              )
          else:
              hist_fct_pc_start, hist_fct_pc_end = None, None
          if future_covariates is not None:
              hist_fct_fc_start = future_covariates.get_index_at_point(
                  hist_fct_fc_start
              )
              hist_fct_fc_end = (
                  future_covariates.get_index_at_point(hist_fct_fc_end)
                  + 1
              )
          else:
              hist_fct_fc_start, hist_fct_fc_end = None, None
  
      return (
          historical_forecasts_time_index[0],
          historical_forecasts_time_index[1],
          hist_fct_tgt_start,
          hist_fct_tgt_end,
          hist_fct_pc_start,
          hist_fct_pc_end,
          hist_fct_fc_start,
          hist_fct_fc_end,
      )
  
imports: from types import SimpleNamespace
  from typing import Any, Callable, Dict, Optional, Sequence, Set, Tuple, Union
  import inspect
  import numpy
  import pandas
  from numpy.typing import ArrayLike
  from darts.logging import get_logger, raise_if_not, raise_log
  from darts.timeseries import TimeSeries
  from darts.utils.timeseries_generation import generate_index
  from darts.utils.utils import series2seq
label_desc: Use image node_id 10 for calling a global function with example usage: _get_historical_forecast_boundaries(model, series, series_idx, past_covariates, future_covariates, start, start_format, forecast_horizon, overlap_end, freq, show_warnings) and returns: historical_forecasts_time_index,  historical_forecasts_time_index,  hist_fct_tgt_start,  hist_fct_tgt_end,  hist_fct_pc_start,  hist_fct_pc_end,  hist_fct_fc_start,  hist_fct_fc_end