code: def _process_historical_forecast_input(
      model,
      series: Optional[Sequence[TimeSeries]],
      past_covariates: Optional[Sequence[TimeSeries]] = None,
      future_covariates: Optional[Sequence[TimeSeries]] = None,
      forecast_horizon: int = 1,
      allow_autoregression: bool = False,
  ):
      if not model._fit_called:
          raise_log(
              ValueError("Model has not been fit yet."),
              logger,
          )
  
      if (
          not allow_autoregression
          and forecast_horizon > model.output_chunk_length
      ):
          raise_log(
              ValueError(
                  "`forecast_horizon > model.output_chunk_length` requires auto-regression which is not "
                  "supported in this optimized routine."
              ),
              logger,
          )
  
      # manage covariates, usually handled by RegressionModel.predict()
      if (
          past_covariates is None
          and model.past_covariate_series is not None
      ):
          past_covariates = [model.past_covariate_series] * len(series)
      if (
          future_covariates is None
          and model.future_covariate_series is not None
      ):
          future_covariates = [model.future_covariate_series] * len(
              series
          )
  
      model._verify_static_covariates(series[0].static_covariates)
  
      if model.encoders.encoding_available:
          (
              past_covariates,
              future_covariates,
          ) = model.generate_fit_predict_encodings(
              n=forecast_horizon,
              series=series,
              past_covariates=past_covariates,
              future_covariates=future_covariates,
          )
      return series, past_covariates, future_covariates
  
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 12 for calling a global function with example usage: _process_historical_forecast_input(model, series, past_covariates, future_covariates, forecast_horizon, allow_autoregression) and returns: series,  past_covariates,  future_covariates