code: def test_stochastic_regression_ensemble_model(self):
      quantiles = [0.25, 0.5, 0.75]
  
      # probabilistic ensembling model
      linreg_prob = LinearRegressionModel(
          quantiles=quantiles,
          lags_future_covariates=[0],
          likelihood="quantile",
      )
  
      # deterministic ensembling model
      linreg_dete = LinearRegressionModel(lags_future_covariates=[0])
  
      # every models are probabilistic
      ensemble_allproba = RegressionEnsembleModel(
          forecasting_models=[
              self.get_probabilistic_global_model(
                  lags=[-1, -3], quantiles=quantiles
              ),
              self.get_probabilistic_global_model(
                  lags=[-2, -4], quantiles=quantiles
              ),
          ],
          regression_train_n_points=10,
          regression_model=linreg_prob.untrained_model(),
      )
  
      assert ensemble_allproba._models_are_probabilistic
      assert ensemble_allproba._is_probabilistic
      ensemble_allproba.fit(self.ts_random_walk[:100])
      # probabilistic forecasting is supported
      pred = ensemble_allproba.predict(5, num_samples=10)
      assert pred.n_samples == 10
  
      # forecasting models are a mix of probabilistic and deterministic, probabilistic regressor
      ensemble_mixproba = RegressionEnsembleModel(
          forecasting_models=[
              self.get_probabilistic_global_model(
                  lags=[-1, -3], quantiles=quantiles
              ),
              self.get_deterministic_global_model(lags=[-2, -4]),
          ],
          regression_train_n_points=10,
          regression_model=linreg_prob.untrained_model(),
      )
  
      assert not ensemble_mixproba._models_are_probabilistic
      assert ensemble_mixproba._is_probabilistic
      ensemble_mixproba.fit(self.ts_random_walk[:100])
      # probabilistic forecasting is supported
      pred = ensemble_mixproba.predict(5, num_samples=10)
      assert pred.n_samples == 10
  
      # forecasting models are a mix of probabilistic and deterministic, probabilistic regressor
      # with regression_train_num_samples > 1
      ensemble_mixproba2 = RegressionEnsembleModel(
          forecasting_models=[
              self.get_probabilistic_global_model(
                  lags=[-1, -3], quantiles=quantiles
              ),
              self.get_deterministic_global_model(lags=[-2, -4]),
          ],
          regression_train_n_points=10,
          regression_model=linreg_prob.untrained_model(),
          regression_train_num_samples=100,
          regression_train_samples_reduction="median",
      )
  
      assert not ensemble_mixproba2._models_are_probabilistic
      assert ensemble_mixproba2._is_probabilistic
      ensemble_mixproba2.fit(self.ts_random_walk[:100])
      pred = ensemble_mixproba2.predict(5, num_samples=10)
      assert pred.n_samples == 10
  
      # only regression model is probabilistic
      ensemble_proba_reg = RegressionEnsembleModel(
          forecasting_models=[
              self.get_deterministic_global_model(lags=[-1, -3]),
              self.get_deterministic_global_model(lags=[-2, -4]),
          ],
          regression_train_n_points=10,
          regression_model=linreg_prob.untrained_model(),
      )
  
      assert not ensemble_proba_reg._models_are_probabilistic
      assert ensemble_proba_reg._is_probabilistic
      ensemble_proba_reg.fit(self.ts_random_walk[:100])
      # probabilistic forecasting is supported
      pred = ensemble_proba_reg.predict(5, num_samples=10)
      assert pred.n_samples == 10
  
      # every models but regression model are probabilistics
      ensemble_dete_reg = RegressionEnsembleModel(
          forecasting_models=[
              self.get_probabilistic_global_model(
                  lags=[-1, -3], quantiles=quantiles
              ),
              self.get_probabilistic_global_model(
                  lags=[-2, -4], quantiles=quantiles
              ),
          ],
          regression_train_n_points=10,
          regression_model=linreg_dete.untrained_model(),
      )
  
      assert ensemble_dete_reg._models_are_probabilistic
      assert not ensemble_dete_reg._is_probabilistic
      ensemble_dete_reg.fit(self.ts_random_walk[:100])
      # deterministic forecasting is supported
      ensemble_dete_reg.predict(5, num_samples=1)
      # probabilistic forecasting is not supported
      with pytest.raises(ValueError):
          ensemble_dete_reg.predict(5, num_samples=10)
  
      # every models are deterministic
      ensemble_alldete = RegressionEnsembleModel(
          forecasting_models=[
              self.get_deterministic_global_model([-1, -3]),
              self.get_deterministic_global_model([-2, -4]),
          ],
          regression_train_n_points=10,
          regression_model=linreg_dete.untrained_model(),
      )
  
      assert not ensemble_alldete._models_are_probabilistic
      assert not ensemble_alldete._is_probabilistic
      ensemble_alldete.fit(self.ts_random_walk[:100])
      # deterministic forecasting is supported
      ensemble_alldete.predict(5, num_samples=1)
      # probabilistic forecasting is not supported
      with pytest.raises(ValueError):
          ensemble_alldete.predict(5, num_samples=10)
  
      # deterministic forecasters cannot be sampled
      with pytest.raises(ValueError):
          RegressionEnsembleModel(
              forecasting_models=[
                  self.get_deterministic_global_model(lags=[-1, -3]),
                  self.get_deterministic_global_model(lags=[-2, -4]),
              ],
              regression_train_n_points=10,
              regression_model=linreg_prob.untrained_model(),
              regression_train_num_samples=10,
          )
  
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 22 for calling the TestRegressionEnsembleModels obj's underlying member method code with example usage: obj.test_stochastic_regression_ensemble_model() without return types