class_docstr: Tests for Hager Zhang line search algorithm.
class_docstr_tok: ["Tests","for","Hager","Zhang","line","search","algorithm","."]
code: def _test_eval_count_eager(self, start):
      def get_val_and_grad_fn():
          def _val_and_grad_fn(x):
              _val_and_grad_fn.num_calls += 1
              f = x * x - 2 * x + 1
              df = 2 * (x - 1)
              return ValueAndGradient(x, f, df)
  
          _val_and_grad_fn.num_calls = 0
          return _val_and_grad_fn
  
      fdf = get_val_and_grad_fn()
      results = self.evaluate(
          hager_zhang(fdf, initial_step_size=tf.constant(start))
      )
      self.assertEqual(fdf.num_calls, results.func_evals)
  
imports: import collections
  from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.optimizer.linesearch.hager_zhang import hager_zhang
label_desc: Use image node_id 7 for calling the HagerZhangTest obj's underlying member method code with example usage: obj._test_eval_count_eager(start) and returns: _val_and_grad_fn, ValueAndGradient