code: def testReduce(self):
      for dtype in set(self.numeric_types).intersection(
          set([dtypes.bfloat16.as_numpy_dtype, np.float32])
      ):
  
          @function.Defun(
              dtype, dtype
          )  # pylint: disable=cell-var-from-loop
          def sum_reducer(x, y):
              return x + y
  
          def sum_reduction(dims):
              def fn(x):
                  return xla.reduce(
                      x,
                      init_value=0,
                      dimensions_to_reduce=dims,
                      reducer=sum_reducer,  # pylint: disable=cell-var-from-loop
                  )
  
              return fn
  
          self._assertOpOutputMatchesExpected(
              sum_reduction(dims=[]),
              args=(
                  np.arange(12, dtype=np.int32)
                  .astype(dtype)
                  .reshape([3, 4]),
              ),
              expected=np.arange(12, dtype=np.int32)
              .astype(dtype)
              .reshape([3, 4]),
          )
          self._assertOpOutputMatchesExpected(
              sum_reduction(dims=[0]),
              args=(
                  np.arange(12, dtype=np.int32)
                  .astype(dtype)
                  .reshape([3, 4]),
              ),
              expected=np.array([12, 15, 18, 21], dtype=dtype),
          )
          self._assertOpOutputMatchesExpected(
              sum_reduction(dims=[1]),
              args=(
                  np.arange(12, dtype=np.int32)
                  .astype(dtype)
                  .reshape([3, 4]),
              ),
              expected=np.array([6, 22, 38], dtype=dtype),
          )
          self._assertOpOutputMatchesExpected(
              sum_reduction(dims=[0, 1]),
              args=(
                  np.arange(12, dtype=np.int32)
                  .astype(dtype)
                  .reshape([3, 4]),
              ),
              expected=dtype(66),
          )
  
          @function.Defun(
              dtype, dtype
          )  # pylint: disable=cell-var-from-loop
          def mul_reducer(x, y):
              return x * y
  
          def mul_reduction(dims):
              def fn(x):
                  return xla.reduce(
                      x,
                      init_value=1,
                      dimensions_to_reduce=dims,
                      reducer=mul_reducer,  # pylint: disable=cell-var-from-loop
                  )
  
              return fn
  
          self._assertOpOutputMatchesExpected(
              mul_reduction(dims=[0]),
              args=(
                  np.arange(12, dtype=np.int32)
                  .astype(dtype)
                  .reshape([3, 4]),
              ),
              expected=np.array([0, 45, 120, 231], dtype=dtype),
          )
  
imports: import functools
  from absl.testing import parameterized
  import numpy
  from tensorflow.compiler.tests import xla_test
  from tensorflow.compiler.tf2xla.ops import gen_xla_ops
  from tensorflow.compiler.tf2xla.python import xla
  from local_xla.xla import xla_data_pb2
  from tensorflow.python.eager import def_function
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import function
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor_shape
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import array_ops_stack
  from tensorflow.python.ops import random_ops_util
  from tensorflow.python.platform import googletest
label_desc: Use image node_id 16 for calling the XlaOpsNumericalTest obj's underlying member method code with example usage: obj.testReduce() and returns: unknown, fn, unknown, fn, xla, xla