code: def _cg(f_Ax, b, cg_iters=10, residual_tol=1e-10):
      """Use Conjugate Gradient iteration to solve Ax = b. Demmel p 312.
  
      Args:
          f_Ax (function): A function to compute Hessian vector product.
          b (numpy.ndarray): Right hand side of the equation to solve.
          cg_iters (int): Number of iterations to run conjugate gradient
              algorithm.
          residual_tol (float): Tolerence for convergence.
  
      Returns:
          numpy.ndarray: Solution x* for equation Ax = b.
  
      """
      p = b.copy()
      r = b.copy()
      x = np.zeros_like(b)
      rdotr = r.dot(r)
  
      for _ in range(cg_iters):
          z = f_Ax(p)
          v = rdotr / p.dot(z)
          x += v * p
          r -= v * z
          newrdotr = r.dot(r)
          mu = newrdotr / rdotr
          p = r + mu * p
  
          rdotr = newrdotr
          if rdotr < residual_tol:
              break
      return x
  
imports: import abc
  from dowel import logger
  import numpy
  import tensorflow
  from garage.tf import compile_function, flatten_tensor_variables, new_tensor_like
  from garage.tf.optimizers._dtypes import LazyDict
label_desc: Use image node_id 1 for calling a global function with example usage: _cg(f_Ax, b, cg_iters, residual_tol) and returns: x