code: def garch_model(x, p, q):
      np.random.seed(1)
      x0 = np.repeat(0.1, p + q + 1)
      bnds = ((0, None),) * len(x0)
      cons = {"type": "ineq", "fun": garch_cons}
      opt = minimize(
          garch_loglik,
          x0,
          args=(x, p, q),
          method="SLSQP",
          bounds=bnds,
          constraints=cons,
      )
  
      coeff = opt.x
      sigma2 = garch_sigma2(coeff, x, p, q)
      fitted = np.full((len(x),), np.nan)
  
      for k in range(p, len(x)):
          error = np.random.normal(loc=0, scale=1)
          fitted[k] = error * np.sqrt(sigma2[k])
  
      res = {
          "p": p,
          "q": q,
          "coeff": coeff,
          "message": opt.message,
          "y_vals": x[-p:],
          "sigma2_vals": sigma2[-q:],
          "fitted": fitted,
      }
  
      return res
  
file_path: statsforecast/statsforecast/garch.py
imports: import numpy
  from numba import njit
  from scipy.optimize import minimize
  from .utils import CACHE, NOGIL
label_desc: Use image node_id 5 for calling a global function with example usage: garch_model(x, p, q) and returns: res