docstr: Tests that the output of 'tf_reduce_fn' matches numpy's output.
docstr_tok: ["Tests","that","the","output","of","'tf_reduce_fn","'","matches","numpy","'s","output","."]
code: def _testReduction(
      self,
      tf_reduce_fn,
      np_reduce_fn,
      dtype,
      test_inputs,
      index_dtype,
      rtol=1e-4,
      atol=1e-4,
  ):
      """Tests that the output of 'tf_reduce_fn' matches numpy's output."""
  
      for test_input in test_inputs:
          with self.session() as sess:
              with self.test_scope():
                  a = array_ops.placeholder(dtype)
                  index = array_ops.placeholder(index_dtype)
                  out = tf_reduce_fn(a, index)
              result = sess.run(out, {a: test_input, index: [0]})
              self.assertAllClose(
                  result,
                  np_reduce_fn(test_input, axis=0),
                  rtol=rtol,
                  atol=atol,
              )
  
              result = sess.run(out, {a: test_input, index: [1]})
              self.assertAllClose(
                  result,
                  np_reduce_fn(test_input, axis=1),
                  rtol=rtol,
                  atol=atol,
              )
  
              result = sess.run(out, {a: test_input, index: [-1]})
              self.assertAllClose(
                  result,
                  np_reduce_fn(test_input, axis=1),
                  rtol=rtol,
                  atol=atol,
              )
  
              # MLIR bridge doesn't return the same error so it can't be matched
              # directly.
              if not test_util.is_mlir_bridge_enabled():
                  with self.assertRaisesWithPredicateMatch(
                      errors_impl.InvalidArgumentError,
                      "Invalid reduction dim",
                  ):
                      sess.run(out, {a: test_input, index: [-33]})
  
                  with self.assertRaisesWithPredicateMatch(
                      errors_impl.InvalidArgumentError,
                      "Invalid reduction dim",
                  ):
                      sess.run(out, {a: test_input, index: [2]})
  
imports: import functools
  import itertools
  from absl.testing import parameterized
  import numpy
  from tensorflow.compiler.tests import xla_test
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors_impl
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.platform import googletest
label_desc: Use image node_id 1 for calling the ReduceOpsTest obj's underlying member method code with example usage: obj._testReduction(tf_reduce_fn, np_reduce_fn, dtype, test_inputs, index_dtype, rtol, atol) without return types