code: def test_constant_variance_simulation(self):
      t = self.t
      dist = Normal(seed=self.rng)
      rng = dist.simulate([])
      vol = ConstantVariance()
      params = np.array([10.0])
      backcast = vol.backcast(self.resid)
      var_bounds = vol.variance_bounds(self.resid)
  
      with preserved_state(self.rng):
          forecast = vol.forecast(
              params,
              self.resid,
              backcast,
              var_bounds,
              horizon=1,
              method="simulation",
              rng=rng,
          )
      assert forecast.forecasts.shape == (1, 1)
      assert forecast.forecast_paths.shape == (1, 1000, 1)
      assert forecast.shocks.shape == (1, 1000, 1)
      assert np.all(np.isfinite(forecast.forecasts))
      assert np.all(forecast.forecasts == params[0])
      assert np.all(np.isfinite(forecast.forecast_paths))
      assert np.all(forecast.forecast_paths == params[0])
      assert np.all(np.isfinite(forecast.shocks))
      assert_allclose(
          forecast.shocks[-1], np.sqrt(params[0]) * rng((1000, 1))
      )
  
      with preserved_state(self.rng):
          forecast = vol.forecast(
              params,
              self.resid,
              backcast,
              var_bounds,
              horizon=5,
              method="simulation",
              rng=rng,
          )
      assert forecast.forecasts.shape == (1, 5)
      assert forecast.forecast_paths.shape == (1, 1000, 5)
      assert forecast.shocks.shape == (1, 1000, 5)
      assert np.all(np.isfinite(forecast.forecasts))
      assert np.all(forecast.forecasts[-1] == params[0])
      assert np.all(np.isfinite(forecast.forecast_paths))
      assert np.all(forecast.forecast_paths[-1] == params[0])
      assert_allclose(
          forecast.shocks[-1], np.sqrt(params[0]) * rng((1000, 5))
      )
  
      with preserved_state(self.rng):
          forecast = vol.forecast(
              params,
              self.resid,
              backcast,
              var_bounds,
              horizon=5,
              start=100,
              method="simulation",
              simulations=2000,
              rng=rng,
          )
      # TODO: This is not correct.  Should be (900,5)
      assert forecast.forecasts.shape == (900, 5)
      assert forecast.forecast_paths.shape == (900, 2000, 5)
      assert forecast.shocks.shape == (900, 2000, 5)
      assert np.all(np.isfinite(forecast.forecasts))
      assert np.all(forecast.forecasts == params[0])
      assert np.all(np.isfinite(forecast.forecast_paths))
      assert np.all(forecast.forecast_paths == params[0])
      expected = np.sqrt(params[0]) * rng((t - 100, 2000, 5))
      expected = np.concatenate((np.empty((100, 2000, 5)), expected))
      assert_allclose(forecast.shocks, expected[100:])
  
imports: import numpy
  from numpy.random import RandomState
  from numpy.testing import assert_allclose
  import pandas
  import pytest
  from arch.univariate import arch_model
  from arch.univariate.distribution import Normal, StudentsT
  from arch.univariate.mean import ConstantMean
  from arch.univariate.volatility import APARCH, EGARCH, FIGARCH, GARCH, HARCH, BootstrapRng, ConstantVariance, EWMAVariance, FixedVariance, MIDASHyperbolic, RiskMetrics2006
label_desc: Use image node_id 22 for calling the TestVarianceForecasts obj's underlying member method code with example usage: obj.test_constant_variance_simulation() without return types