class_docstr: Test class for PearlmutterHvp
class_docstr_tok: ["Test","class","for","PearlmutterHvp"]
docstr: Test Hessian-vector product for a function with one variable.
docstr_tok: ["Test","Hessian-vector","product","for","a","function","with","one","variable","."]
code: def test_pearl_mutter_hvp_1x1(self):
      """Test Hessian-vector product for a function with one variable."""
      policy = HelperPolicy(n_vars=1)
      x = policy.get_params()[0]
      a_val = np.array([5.0])
      a = tf.constant([0.0])
      f = a * (x**2)
      expected_hessian = 2 * a_val
      vector = np.array([10.0])
      expected_hvp = expected_hessian * vector
      reg_coeff = 1e-5
      hvp = PearlmutterHVP()
  
      self.sess.run(tf.compat.v1.global_variables_initializer())
      hvp.update_hvp(f, policy, (a,), reg_coeff)
      hx = hvp.build_eval(np.array([a_val]))
      computed_hvp = hx(vector)
      assert np.allclose(computed_hvp, expected_hvp)
  
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 TestPearlmutterHVP obj's underlying member method code with example usage: obj.test_pearl_mutter_hvp_1x1() without return types