code: def _simple_direct_gjrgarch_forecaster(
      resids, params, p, o, q, backcast, var_bounds, horizon
  ):
      """
      Simple GARCH forecasting for use when testing model-based forecasts
  
      Parameters
      ----------
      resids : ndarray
      params : ndarray
      p : int
      o : int
      q : int
      backcast : float
      var_bounds : ndarray
      horizon : int
  
      Returns
      -------
      forecasts : ndarray
  
      """
      m = max([p, o, q])
      t = resids.shape[0]
      _resids = resids
      _sigma2 = np.empty(t)
      garch_recursion(
          params,
          resids**2.0,
          np.sign(resids),
          _sigma2,
          p,
          o,
          q,
          t,
          backcast,
          var_bounds,
      )
      resids = np.empty((t, m + horizon))
      asymresids = resids.copy()
      sigma2 = np.empty((t, m + horizon))
  
      resids[:, :m] = np.sqrt(backcast)
      asymresids[:, :m] = np.sqrt(0.5 * backcast)
      sigma2[:, :m] = backcast
  
      for i in range(m):
          resids[m - 1 - i :, i] = _resids[: (t - (m - 1) + i)]
          asymresids[m - 1 - i :, i] = _resids[: (t - (m - 1) + i)] * (
              _resids[: (t - (m - 1) + i)] < 0
          )
          sigma2[m - 1 - i :, i] = _sigma2[: (t - (m - 1) + i)]
  
      for i in range(m, m + horizon):
          sigma2[:, i] = params[0]
          ind = 1
          for j in range(p):
              sigma2[:, i] += params[ind] * resids[:, i - j - 1] ** 2.0
              ind += 1
  
          for j in range(o):
              sigma2[:, i] += (
                  params[ind] * asymresids[:, i - j - 1] ** 2.0
              )
              ind += 1
  
          for j in range(q):
              sigma2[:, i] += params[ind] * sigma2[:, i - j - 1]
              ind += 1
          resids[:, i] = np.sqrt(sigma2[:, i])
          asymresids[:, i] = np.sqrt(0.5 * sigma2[:, i])
  
      return sigma2[:, m:]
  
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 2 for calling a global function with example usage: _simple_direct_gjrgarch_forecaster(resids, params, p, o, q, backcast, var_bounds, horizon) and returns: sigma2