class_docstr: Test class for ConjugateGradientOptimizer and HVP classes
class_docstr_tok: ["Test","class","for","ConjugateGradientOptimizer","and","HVP","classes"]
docstr: Solve Ax = b using Conjugate gradient method.
docstr_tok: ["Solve","Ax","=","b","using","Conjugate","gradient","method","."]
code: def test_cg(self):
      """Solve Ax = b using Conjugate gradient method."""
      a = np.linspace(-np.pi, np.pi, 25).reshape((5, 5))
      a = a.T.dot(a)  # make sure a is positive semi-definite
      b = np.linspace(-np.pi, np.pi, 5)
      x = _cg(a.dot, b, cg_iters=5)
      assert np.allclose(a.dot(x), b)
  
imports: import pickle
  import numpy
  import pytest
  import tensorflow
  from garage.tf.models import Module
  from garage.tf.optimizers.conjugate_gradient_optimizer import ConjugateGradientOptimizer
  from garage.tf.optimizers.conjugate_gradient_optimizer import FiniteDifferenceHVP
  from garage.tf.optimizers.conjugate_gradient_optimizer import _cg, PearlmutterHVP
  from garage.tf.policies import Policy
  from tests.fixtures import TfGraphTestCase
label_desc: Use image node_id 1 for calling the TestConjugateGradientOptimizer obj's underlying member method code with example usage: obj.test_cg() without return types