docstr: Callback should run at the end of every iteration.
docstr_tok: ["Callback","should","run","at","the","end","of","every","iteration","."]
code: def test_minimize_callback(self):
      """Callback should run at the end of every iteration."""
      variables = np.random.uniform(low=-1.0, high=1.0, size=[1])
      saved_objective = [None]
      saved_iteration = [None]
      iteration_count = [0]
  
      def callback(iteration, objective_value, variables):
          del variables
  
          def save(iteration, objective_value):
              saved_objective[0] = objective_value
              saved_iteration[0] = iteration
              iteration_count[0] += 1
  
          return tf.py_function(save, [iteration, objective_value], [])
  
      final_objective, _ = levenberg_marquardt.minimize(
          lambda x: x, variables, max_iterations=5, callback=callback
      )
      final_saved_objective = tf.py_function(
          lambda: saved_objective[0], [], tf.float64
      )
      final_saved_iteration = tf.py_function(
          lambda: saved_iteration[0], [], tf.int32
      )
      final_iteration_count = tf.py_function(
          lambda: iteration_count[0], [], tf.int32
      )
  
      with self.subTest(name="objective_value"):
          self.assertAllClose(final_objective, final_saved_objective)
  
      with self.subTest(name="iterations"):
          self.assertAllEqual(
              final_saved_iteration, final_iteration_count
          )
  
file_path: graphics/tensorflow_graphics/math/optimizer/tests/levenberg_marquardt_test.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from absl.testing import parameterized
  import numpy
  from six.moves import zip
  import tensorflow
  from tensorflow_graphics.math.optimizer import levenberg_marquardt
  from tensorflow_graphics.util import test_case
label_desc: Use image node_id 4 for calling the OptimizerTest obj's underlying member method code with example usage: obj.test_minimize_callback() and returns: tf