code: def _testFindsAllRoots(
      self,
      objective_fn,
      left_bracket,
      right_bracket,
      expected_roots,
      expected_num_iterations,
      dtype=tf.float64,
      absolute_root_tolerance=2e-7,
      relative_root_tolerance=None,
      function_tolerance=2e-7,
      assert_check_for_num_iterations=True,
  ):
      # expected_roots are pre-calculated as follows:
      # import scipy.optimize as optimize
      # roots = optimize.brentq(objective_fn,
      #                         left_bracket[i],
      #                         right_bracket[i],
      #                         xtol=absolute_root_tolerance,
      #                         rtol=relative_root_tolerance)
  
      assert len(left_bracket) == len(
          right_bracket
      ), "Brackets have different sizes"
  
      if relative_root_tolerance is None:
          relative_root_tolerance = (
              utils.default_relative_root_tolerance(dtype)
          )
  
      expected_num_iterations, result = self.evaluate(
          [
              tf.constant(expected_num_iterations, dtype=tf.int32),
              brentq(
                  objective_fn,
                  tf.constant(left_bracket, dtype=dtype),
                  tf.constant(right_bracket, dtype=dtype),
                  absolute_root_tolerance=absolute_root_tolerance,
                  relative_root_tolerance=relative_root_tolerance,
                  function_tolerance=function_tolerance,
              ),
          ]
      )
  
      roots, value_at_roots, num_iterations, converged = result
      zeros = [0.0] * len(left_bracket)
  
      # The output of SciPy and Tensorflow implementation should match for
      # well-behaved functions.
      self.assertAllClose(
          roots,
          expected_roots,
          atol=2 * absolute_root_tolerance,
          rtol=2 * relative_root_tolerance,
      )
      self.assertAllClose(
          value_at_roots, zeros, atol=10 * function_tolerance
      )
      if assert_check_for_num_iterations:
          self.assertAllEqual(num_iterations, expected_num_iterations)
      self.assertAllEqual(
          converged,
          [
              abs(value) <= function_tolerance
              for value in value_at_roots
          ],
      )
  
imports: import math
  import tensorflow.compat.v2
  import tf_quant_finance
  from tensorflow.python.framework import test_util
  from tf_quant_finance.math.root_search import utils
label_desc: Use image node_id 1 for calling the BrentqTest obj's underlying member method code with example usage: obj._testFindsAllRoots(objective_fn, left_bracket, right_bracket, expected_roots, expected_num_iterations, dtype, absolute_root_tolerance, relative_root_tolerance, function_tolerance, assert_check_for_num_iterations) without return types