code: def _cg_solve(OtOr, X, y, w, epochs):
      """
      Use conjugate gradient method to solve the system M†(X'X + X'yX + λ)w = M†X'(y+1).
      The parameter OtOr = X'X + λ.
      """
      nf = X.shape[1]
      # compute inverse of the Jacobi preconditioner
      Ad = np.diag(OtOr).copy()
      for i in range(X.shape[0]):
          for k in range(nf):
              Ad[k] += X[i, k] * y[i] * X[i, k]
  
      iM = np.reciprocal(Ad)
  
      # compute residuals
      b = X.T @ (y + 1.0)
      r = _cg_a_mult(OtOr, X, y, w)
      r *= -1
      r += b
  
      # compute initial values
      z = iM * r
      p = z
  
      # and solve
      for i in range(epochs):
          gam = np.dot(r, z)
          Ap = _cg_a_mult(OtOr, X, y, p)
          al = gam / np.dot(p, Ap)
          _inplace_axpy(al, p, w)
          _inplace_axpy(-al, Ap, r)
          z = iM * r
          bet = np.dot(r, z) / gam
          p = z + bet * p
  
imports: import logging
  from collections import namedtuple
  import numpy
  from numba import njit, prange
  from csr import CSR
  from seedbank import numpy_rng
  from .bias import Bias
  from .mf_common import MFPredictor
  from ..data import sparse_ratings
  from ..None import util
  from ..math.solve import _dposv
label_desc: Use image node_id 7 for calling a global function with example usage: _cg_solve(OtOr, X, y, w, epochs) without return types