code: def _get_historical_forecast_train_index(
      model,
      series: TimeSeries,
      series_idx: int,
      past_covariates: Optional[TimeSeries],
      future_covariates: Optional[TimeSeries],
      forecast_horizon: int,
      overlap_end: bool,
  ) -> TimeIndex:
      """
      Obtain the boundaries of the time indices usable for training, raise an exception if training is required and
      no indices are available.
      """
      historical_forecasts_time_index = (
          _get_historical_forecastable_time_index(
              model=model,
              series=series,
              forecast_horizon=forecast_horizon,
              overlap_end=overlap_end,
              past_covariates=past_covariates,
              future_covariates=future_covariates,
              is_training=True,
              reduce_to_bounds=True,
          )
      )
  
      if (
          not model._fit_called
          and historical_forecasts_time_index is None
      ):
          raise_log(
              ValueError(
                  "Cannot build a single input for training with the provided untrained model, "
                  f"`series` and `*_covariates` at series index: {series_idx}. The minimum "
                  "training input time index requirements were not met. "
                  "Please check the time index of `series` and `*_covariates`."
              ),
              logger,
          )
  
      return historical_forecasts_time_index
  
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 8 for calling a global function with example usage: _get_historical_forecast_train_index(model, series, series_idx, past_covariates, future_covariates, forecast_horizon, overlap_end) and returns: historical_forecasts_time_index