class_docstr: Abstract base class for ensemble models.
  Ensemble models take in a list of forecasting models and ensemble their predictions
  to make a single one according to the rule defined by their `ensemble()` method.
  
  If `future_covariates` or `past_covariates` are provided at training or inference time,
  they will be passed only to the models supporting them.
  
  Parameters
  ----------
  forecasting_models
      List of forecasting models whose predictions to ensemble
  
      .. note::
              if all the models are probabilistic, the `EnsembleModel` will also be probabilistic.
      ..
  train_num_samples
      Number of prediction samples from each forecasting model for multi-level ensembles. The n_samples
      dimension will be reduced using the `train_samples_reduction` method.
  train_samples_reduction
      If `forecasting_models` are probabilistic and `train_num_samples` > 1, method used to reduce the
      samples dimension to 1. Possible values: "mean", "median" or float value corresponding to the
      desired quantile.
  retrain_forecasting_models
      If set to `False`, the `forecasting_models` are not retrained when calling `fit()` (only supported
      if all the `forecasting_models` are pretrained `GlobalForecastingModels`). Default: ``True``.
  show_warnings
      Whether to show warnings related to models covariates support.
class_docstr_tok: ["Abstract","base","class","for","ensemble","models",".","Ensemble","models","take","in","a","list","of","forecasting","models","and","ensemble","their","predictions","to","make","a","single","one","according","to","the","rule","defined","by","their","`","ensemble","(",")","`","method",".","If","`","future_covariates","`","or","`","past_covariates","`","are","provided","at","training","or","inference","time",",","they","will","be","passed","only","to","the","models","supporting","them",".","Parameters","--","--","--","--","--","forecasting_models","List","of","forecasting","models","whose","predictions","to","ensemble","..","note",":",":","if","all","the","models","are","probabilistic",",","the","`","EnsembleModel","`","will","also","be","probabilistic",".","..","train_num_samples","Number","of","prediction","samples","from","each","forecasting","model","for","multi-level","ensembles",".","The","n_samples","dimension","will","be","reduced","using","the","`","train_samples_reduction","`","method",".","train_samples_reduction","If","`","forecasting_models","`","are","probabilistic","and","`","train_num_samples","`",">","1",",","method","used","to","reduce","the","samples","dimension","to","1",".","Possible","values",":","``","mean","''",",","``","median","''","or","float","value","corresponding","to","the","desired","quantile",".","retrain_forecasting_models","If","set","to","`","False","`",",","the","`","forecasting_models","`","are","not","retrained","when","calling","`","fit","(",")","`","(","only","supported","if","all","the","`","forecasting_models","`","are","pretrained","`","GlobalForecastingModels","`",")",".","Default",":","``","True","``",".","show_warnings","Whether","to","show","warnings","related","to","models","covariates","support","."]
code: def __init__(
      self,
      forecasting_models: List[ForecastingModel],
      train_num_samples: int,
      train_samples_reduction: Optional[Union[str, float]],
      train_forecasting_models: bool = True,
      show_warnings: bool = True,
  ):
      raise_if_not(
          isinstance(forecasting_models, list) and forecasting_models,
          "Cannot instantiate EnsembleModel with an empty list of `forecasting_models`",
          logger,
      )
  
      is_local_model = [
          isinstance(model, LocalForecastingModel)
          for model in forecasting_models
      ]
      is_global_model = [
          isinstance(model, GlobalForecastingModel)
          for model in forecasting_models
      ]
  
      self.is_local_ensemble = all(is_local_model)
      self.is_global_ensemble = all(is_global_model)
  
      raise_if_not(
          all(
              [
                  local_model or global_model
                  for local_model, global_model in zip(
                      is_local_model, is_global_model
                  )
              ]
          ),
          "All models must be of type `GlobalForecastingModel`, or `LocalForecastingModel`. "
          "Also, make sure that all `forecasting_models` are instantiated.",
          logger,
      )
  
      model_fit_status = [m._fit_called for m in forecasting_models]
      self.all_trained = all(model_fit_status)
      some_trained = any(model_fit_status)
  
      raise_if(
          (not self.is_global_ensemble and some_trained)
          or (
              self.is_global_ensemble
              and not (self.all_trained or not some_trained)
          ),
          "Cannot instantiate EnsembleModel with a mixture of unfitted and fitted `forecasting_models`. "
          "Consider resetting all models with `my_model.untrained_model()` or using only trained "
          "GlobalForecastingModels together with `retrain_forecasting_models=False`.",
          logger,
      )
  
      if train_forecasting_models:
          # prevent issues with pytorch-lightning trainer during retraining
          raise_if(
              some_trained,
              "`retrain_forecasting_models=True` but some `forecasting_models` were already fitted. "
              "Consider resetting all the `forecasting_models` with `my_model.untrained_model()` "
              "before passing them to the `EnsembleModel`.",
              logger,
          )
      else:
          raise_if_not(
              self.is_global_ensemble and self.all_trained,
              "`retrain_forecasting_models=False` is supported only if all the `forecasting_models` are "
              "already trained `GlobalForecastingModels`.",
              logger,
          )
  
      raise_if(
          train_num_samples is not None
          and train_num_samples > 1
          and all(
              [not m._is_probabilistic for m in forecasting_models]
          ),
          "`train_num_samples` is greater than 1 but the `RegressionEnsembleModel` "
          "contains only deterministic `forecasting_models`.",
          logger,
      )
  
      supported_reduction = ["mean", "median"]
      if train_samples_reduction is None:
          pass
      elif isinstance(train_samples_reduction, float):
          raise_if_not(
              0.0 < train_samples_reduction < 1.0,
              f"if a float, `train_samples_reduction` must be between "
              f"0 and 1, received ({train_samples_reduction})",
              logger,
          )
      elif isinstance(train_samples_reduction, str):
          raise_if(
              train_samples_reduction not in supported_reduction,
              f"if a string, `train_samples_reduction` must be one of {supported_reduction}, "
              f"received ({train_samples_reduction})",
              logger,
          )
      else:
          raise_log(
              ValueError(
                  f"`train_samples_reduction` type not supported "
                  f"({train_samples_reduction}). Must be `float` "
                  f" or one of {supported_reduction}."
              ),
              logger,
          )
  
      super().__init__()
      self.forecasting_models = forecasting_models
      self.train_num_samples = train_num_samples
      self.train_samples_reduction = train_samples_reduction
      self.train_forecasting_models = train_forecasting_models
      self.show_warnings = show_warnings
  
      if show_warnings:
          if (
              self.supports_past_covariates
              and not self._full_past_covariates_support()
          ):
              logger.warning(
                  "Some `forecasting_models` in the ensemble do not support past covariates, the past covariates "
                  "will be provided only to the models supporting them when calling fit()` or `predict()`. "
                  "To hide these warnings, set `show_warnings=False`."
              )
  
          if (
              self.supports_future_covariates
              and not self._full_future_covariates_support()
          ):
              logger.warning(
                  "Some `forecasting_models` in the ensemble do not support future covariates, the future covariates"
                  " will be provided only to the models supporting them when calling `fit()` or `predict()`. "
                  "To hide these warnings, set `show_warnings=False`."
              )
  
imports: from abc import abstractmethod
  from typing import List, Optional, Sequence, Tuple, Union
  from darts.logging import get_logger, raise_if, raise_if_not, raise_log
  from darts.models.forecasting.forecasting_model import ForecastingModel, GlobalForecastingModel, LocalForecastingModel
  from darts.timeseries import TimeSeries, concatenate
  from darts.utils.utils import series2seq
label_desc: Use image node_id 1 to create a new EnsembleModel object from inherited base classes: GlobalForecastingModel with example: obj = EnsembleModel(forecasting_models, train_num_samples, train_samples_reduction, train_forecasting_models, show_warnings)