code: def test_stochastic_naive_ensemble(self):
      num_samples = 100
  
      # probabilistic forecasting models
      model_proba_1 = LinearRegressionModel(
          lags=1, likelihood="quantile", random_state=42
      )
      model_proba_2 = LinearRegressionModel(
          lags=2, likelihood="quantile", random_state=42
      )
  
      # only probabilistic forecasting models
      naive_ensemble_proba = NaiveEnsembleModel(
          [model_proba_1, model_proba_2]
      )
      assert naive_ensemble_proba._is_probabilistic
  
      naive_ensemble_proba.fit(self.series1 + self.series2)
      # by default, only 1 sample
      pred_proba_1_sample = naive_ensemble_proba.predict(n=5)
      assert pred_proba_1_sample.n_samples == 1
  
      # possible to obtain probabilistic forecast by averaging samples across the models
      pred_proba_many_sample = naive_ensemble_proba.predict(
          n=5, num_samples=num_samples
      )
      assert pred_proba_many_sample.n_samples == num_samples
  
      # need to redefine the models to reset the random state
      model_alone_1 = LinearRegressionModel(
          lags=1, likelihood="quantile", random_state=42
      )
      model_alone_2 = LinearRegressionModel(
          lags=2, likelihood="quantile", random_state=42
      )
      model_alone_1.fit(self.series1 + self.series2)
      model_alone_2.fit(self.series1 + self.series2)
      forecast_mean = 0.5 * model_alone_1.predict(
          5, num_samples=num_samples
      ) + 0.5 * model_alone_2.predict(5, num_samples=num_samples)
  
      assert (
          forecast_mean.values().shape
          == pred_proba_many_sample.values().shape
      )
      assert forecast_mean.n_samples == pred_proba_many_sample.n_samples
      np.testing.assert_array_equal(
          pred_proba_many_sample.values(), forecast_mean.values()
      )
  
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 9 for calling the TestEnsembleModels obj's underlying member method code with example usage: obj.test_stochastic_naive_ensemble() without return types