code: def test_builder_eval(self, axis, keep_dims):
      x_val = random_gen(
          shape=(1, 3, 4, 4), rand_min=-100.0, rand_max=100.0
      )
  
      @ssa_fn
      def test_reduce_argmax():
          res = mb.reduce_argmax(
              x=x_val, axis=axis, keep_dims=keep_dims
          ).val
          ref = np.argmax(x_val, axis=axis)
          if keep_dims:
              ref = np.expand_dims(ref, axis=axis)
          np.testing.assert_allclose(ref, res, atol=1e-04, rtol=1e-05)
  
      @ssa_fn
      def test_reduce_argmin():
          res = mb.reduce_argmin(
              x=x_val, axis=axis, keep_dims=keep_dims
          ).val
          ref = np.argmin(x_val, axis=axis)
          if keep_dims:
              ref = np.expand_dims(ref, axis=axis)
          np.testing.assert_allclose(ref, res, atol=1e-04, rtol=1e-05)
  
      @ssa_fn
      def test_reduce_l1_norm():
          res = mb.reduce_l1_norm(
              x=x_val, axes=[axis], keep_dims=keep_dims
          ).val
          ref = np.sum(np.abs(x_val), axis=axis, keepdims=keep_dims)
          np.testing.assert_allclose(ref, res, atol=1e-04, rtol=1e-05)
  
      @ssa_fn
      def test_reduce_l2_norm():
          res = mb.reduce_l2_norm(
              x=x_val, axes=[axis], keep_dims=keep_dims
          ).val
          ref = np.sqrt(
              np.sum(np.square(x_val), axis=axis, keepdims=keep_dims)
          )
          np.testing.assert_allclose(ref, res, atol=1e-04, rtol=1e-05)
  
      @ssa_fn
      def test_reduce_log_sum():
          x_val = random_gen(
              shape=(1, 3, 4, 4), rand_min=0.0, rand_max=100.0
          )
          res = mb.reduce_log_sum(
              x=x_val, axes=[axis], keep_dims=keep_dims
          ).val
          ref = np.log(np.sum(x_val, axis=axis, keepdims=keep_dims))
          np.testing.assert_allclose(ref, res, atol=1e-04, rtol=1e-05)
  
      @ssa_fn
      def test_reduce_log_sum_exp():
          res = mb.reduce_log_sum_exp(
              x=x_val, axes=[axis], keep_dims=keep_dims
          ).val
          ref = scipy.special.logsumexp(
              x_val, axis=axis, keepdims=keep_dims
          )
          np.testing.assert_allclose(ref, res, atol=1e-04, rtol=1e-05)
  
      @ssa_fn
      def test_reduce_max():
          res = mb.reduce_max(
              x=x_val, axes=[axis], keep_dims=keep_dims
          ).val
          ref = np.max(x_val, axis=axis, keepdims=keep_dims)
          np.testing.assert_allclose(ref, res, atol=1e-04, rtol=1e-05)
  
      @ssa_fn
      def test_reduce_mean():
          res = mb.reduce_mean(
              x=x_val, axes=[axis], keep_dims=keep_dims
          ).val
          ref = np.mean(x_val, axis=axis, keepdims=keep_dims)
          np.testing.assert_allclose(ref, res, atol=1e-04, rtol=1e-05)
  
      @ssa_fn
      def test_reduce_min():
          res = mb.reduce_min(
              x=x_val, axes=[axis], keep_dims=keep_dims
          ).val
          ref = np.min(x_val, axis=axis, keepdims=keep_dims)
          np.testing.assert_allclose(ref, res, atol=1e-04, rtol=1e-05)
  
      @ssa_fn
      def test_reduce_prod():
          # test  value
          res = mb.reduce_prod(
              x=x_val, axes=[axis], keep_dims=keep_dims
          ).val
          ref = np.prod(x_val, axis=axis, keepdims=keep_dims)
          np.testing.assert_allclose(ref, res, atol=1e-04, rtol=1e-05)
  
          # test dtype for int input
          res = mb.reduce_prod(
              x=x_val.astype(np.int32), axes=[axis], keep_dims=keep_dims
          ).val
          assert res.dtype == np.int32
  
      @ssa_fn
      def test_reduce_sum():
          res = mb.reduce_sum(
              x=x_val, axes=[axis], keep_dims=keep_dims
          ).val
          ref = np.sum(x_val, axis=axis, keepdims=keep_dims)
          np.testing.assert_allclose(ref, res, atol=1e-04, rtol=1e-05)
  
      @ssa_fn
      def test_reduce_sum_square():
          res = mb.reduce_sum_square(
              x=x_val, axes=[axis], keep_dims=keep_dims
          ).val
          ref = np.sum(np.square(x_val), axis=axis, keepdims=keep_dims)
          np.testing.assert_allclose(ref, res, atol=1e-04, rtol=1e-05)
  
      test_reduce_argmax()
      test_reduce_argmin()
      test_reduce_l1_norm()
      test_reduce_l2_norm()
      test_reduce_log_sum()
      test_reduce_log_sum_exp()
      test_reduce_max()
      test_reduce_mean()
      test_reduce_min()
      test_reduce_prod()
      test_reduce_sum()
      test_reduce_sum_square()
  
file_path: coremltools/coremltools/converters/mil/mil/ops/tests/iOS14/test_reduction.py
imports: import itertools
  import numpy
  import pytest
  import scipy
  from coremltools.converters.mil.mil import Builder
  from coremltools.converters.mil.mil import get_new_symbol, types
  from coremltools.converters.mil.mil.ops.tests.iOS14 import backends
  from coremltools.converters.mil.mil.ops.tests.testing_utils import run_compare_builder
  from coremltools.converters.mil.testing_reqs import compute_units
  from coremltools.converters.mil.testing_utils import random_gen, ssa_fn
label_desc: Use image node_id 5 for calling the TestReduction obj's underlying member method code with example usage: obj.test_builder_eval(axis, keep_dims) without return types