docstr: EnsembleModels can be instantiated with pre-trained GlobalForecastingModels
docstr_tok: ["EnsembleModels","can","be","instantiated","with","pre-trained","GlobalForecastingModels"]
code: def test_trained_models(self):
      """EnsembleModels can be instantiated with pre-trained GlobalForecastingModels"""
      local_model = NaiveDrift()
      global_model = LinearRegressionModel(lags=2)
      local_model.fit(self.series1)
      global_model.fit(self.series1)
  
      # local and global trained
      with pytest.raises(ValueError):
          NaiveEnsembleModel([local_model, global_model])
  
      # local untrained, global trained
      with pytest.raises(ValueError):
          NaiveEnsembleModel(
              [local_model.untrained_model(), global_model]
          )
  
      # local trained, global untrained
      with pytest.raises(ValueError):
          NaiveEnsembleModel(
              [local_model, global_model.untrained_model()]
          )
  
      # global trained, global untrained
      with pytest.raises(ValueError):
          NaiveEnsembleModel(
              [global_model, global_model.untrained_model()]
          )
  
      # both global trained, retrain = True
      with pytest.raises(ValueError):
          # models need to be explicitely reset before retraining them
          NaiveEnsembleModel(
              [global_model, global_model],
              train_forecasting_models=True,
          )
      model_ens_retrain = NaiveEnsembleModel(
          [
              global_model.untrained_model(),
              global_model.untrained_model(),
          ],
          train_forecasting_models=True,
      )
      with pytest.raises(ValueError):
          model_ens_retrain.predict(1, series=self.series1)
      model_ens_retrain.fit(self.series1)
      model_ens_retrain.predict(1, series=self.series1)
  
      # both global trained, retrain = False
      model_ens_no_retrain = NaiveEnsembleModel(
          [global_model, global_model], train_forecasting_models=False
      )
      model_ens_no_retrain.predict(1, series=self.series1)
  
imports: import numpy
  import pandas
  import pytest
  from darts import TimeSeries
  from darts.logging import get_logger
  from darts.models import ExponentialSmoothing, LinearRegressionModel, NaiveDrift, NaiveEnsembleModel, NaiveSeasonal, StatsForecastAutoARIMA, Theta
  from darts.tests.conftest import tfm_kwargs
  from darts.utils import timeseries_generation
label_desc: Use image node_id 2 for calling the TestEnsembleModels obj's underlying member method code with example usage: obj.test_trained_models() without return types