code: def test_constant_variance(setup):
      cv = ConstantVariance()
  
      sv = cv.starting_values(setup.resids)
      assert_equal(sv.shape[0], cv.num_params)
  
      bounds = cv.bounds(setup.resids)
      mean_square = np.mean(setup.resids**2.0)
      assert_almost_equal(
          bounds[0], (setup.resid_var / 100000.0, 10.0 * mean_square)
      )
  
      backcast = cv.backcast(setup.resids)
      var_bounds = cv.variance_bounds(setup.resids)
      assert_almost_equal(setup.resid_var, backcast)
  
      parameters = np.array([setup.resid_var])
  
      cv.compute_variance(
          parameters, setup.resids, setup.sigma2, backcast, var_bounds
      )
      assert_allclose(
          np.ones_like(setup.sigma2) * setup.resid_var, setup.sigma2
      )
  
      a, b = cv.constraints()
      a_target = np.eye(1)
      b_target = np.array([0.0])
      assert_array_equal(a, a_target)
      assert_array_equal(b, b_target)
  
      state = setup.rng.get_state()
      rng = Normal(seed=RandomState())
      rng.generator.set_state(state)
      sim_data = cv.simulate(parameters, setup.t, rng.simulate([]))
      setup.rng.set_state(state)
      e = setup.rng.standard_normal(setup.t + 500)
      sigma2 = np.zeros(setup.t + 500)
      sigma2[:] = parameters[0]
      data = np.zeros(setup.t + 500)
      data[:] = np.sqrt(sigma2) * e
      data = data[500:]
      sigma2 = sigma2[500:]
  
      names = cv.parameter_names()
      names_target = ["sigma2"]
      assert_equal(names, names_target)
  
      assert_almost_equal(data - sim_data[0] + 1.0, np.ones_like(data))
      assert_almost_equal(sigma2 / sim_data[1], np.ones_like(sigma2))
  
      assert_equal(cv.num_params, 1)
      assert_equal(cv.name, "Constant Variance")
      assert isinstance(cv.__str__(), str)
      txt = cv.__repr__()
      assert str(hex(id(cv))) in txt
  
imports: import types
  from typing import NamedTuple
  import warnings
  import numpy
  from numpy.random import RandomState
  from numpy.testing import assert_allclose, assert_almost_equal, assert_array_equal, assert_equal
  import pytest
  from scipy.special import gamma, gammaln
  from arch.univariate import ZeroMean
  from arch.univariate.distribution import Normal, SkewStudent, StudentsT
  import arch.univariate.recursions_python
  from arch.univariate.volatility import APARCH, ARCH, EGARCH, FIGARCH, GARCH, HARCH, ConstantVariance, EWMAVariance, FixedVariance, MIDASHyperbolic, RiskMetrics2006
  from arch.utility.exceptions import InitialValueWarning
label_desc: Use image node_id 7 for calling a global function with example usage: test_constant_variance(setup) without return types