docstr: config[0] : both ocl = 1, covs are long enough
  config[1] : both ocl are multiple, covs are long enough
  config[2] : ocl1 multiple, ocl2 not multiple
docstr_tok: ["config","[","0","]",":","both","ocl","=","1",",","covs","are","long","enough","config","[","1","]",":","both","ocl","are","multiple",",","covs","are","long","enough","config","[","2","]",":","ocl1","multiple",",","ocl2","not","multiple"]
code: def test_train_with_historical_forecasts_with_covs(self, config):
      """
      config[0] : both ocl = 1, covs are long enough
      config[1] : both ocl are multiple, covs are long enough
      config[2] : ocl1 multiple, ocl2 not multiple
      """
      ocl1, ocl2 = config
      regression_train_n_points = 10
      # shortening the series to make test simpler, 10 for forecasting models, 20 for the regression model
      ts = self.combined[:30]
  
      # past covariates starts 5 steps before the target series
      past_covs = tg.linear_timeseries(
          start=ts.start_time() - 5 * ts.freq,
          length=len(ts) + 5,
      )
  
      ensemble = RegressionEnsembleModel(
          forecasting_models=[
              LinearRegressionModel(
                  lags=5,
                  lags_past_covariates=5,
                  output_chunk_length=ocl1,
              ),
              LinearRegressionModel(
                  lags=2,
                  lags_past_covariates=5,
                  output_chunk_length=ocl2,
              ),
          ],
          regression_train_n_points=regression_train_n_points,
          train_using_historical_forecasts=True,
      )
      # covariates have the appropriate length
      ensemble.fit(ts, past_covariates=past_covs)
      assert (
          len(ensemble.regression_model.training_series)
          == regression_train_n_points
      )
      # since past covariates extend far in the past, they are available for the regression model
  
      # future covariates finishes 5 steps after the target series
      future_covs = tg.linear_timeseries(
          start=ts.start_time(),
          length=len(ts) + 2,
      )
  
      ensemble = RegressionEnsembleModel(
          forecasting_models=[
              LinearRegressionModel(
                  lags=2,
                  lags_future_covariates=[1, 2],
                  output_chunk_length=ocl1,
              ),
              LinearRegressionModel(
                  lags=1,
                  lags_future_covariates=[1, 2],
                  output_chunk_length=ocl2,
              ),
          ],
          regression_train_n_points=regression_train_n_points,
          train_using_historical_forecasts=True,
      )
  
      # covariates have the appropriate length
      ensemble.fit(ts, future_covariates=future_covs)
      assert (
          len(ensemble.regression_model.training_series)
          == regression_train_n_points
      )
  
      with pytest.raises(ValueError):
          # covariates are too short (ends too early)
          ensemble.fit(
              ts, future_covariates=future_covs[: -min(ocl1, ocl2)]
          )
  
imports: from typing import List, Union
  import numpy
  import pandas
  import pytest
  from sklearn.ensemble import RandomForestRegressor
  from sklearn.linear_model import LinearRegression
  from darts import TimeSeries
  from darts.logging import get_logger
  from darts.metrics import mape, rmse
  from darts.models import LinearRegressionModel, NaiveDrift, NaiveSeasonal, RandomForest, RegressionEnsembleModel, RegressionModel, Theta
  from darts.tests.conftest import tfm_kwargs
  from darts.tests.models.forecasting.test_ensemble_models import _make_ts
  from darts.tests.models.forecasting.test_regression_models import train_test_split
  from darts.utils import timeseries_generation
label_desc: Use image node_id 10 for calling the TestRegressionEnsembleModels obj's underlying member method code with example usage: obj.test_train_with_historical_forecasts_with_covs(config) without return types