code: def test_reduce():
      sample_num = 200
  
      def test_reduce_inner(numpy_reduce_func, nd_reduce_func):
          for i in range(sample_num):
              ndim = np.random.randint(1, 6)
              shape = np.random.randint(1, 11, size=ndim)
              axis_flags = np.random.randint(0, 2, size=ndim)
              axes = []
              for axis, flag in enumerate(axis_flags):
                  if flag:
                      axes.append(axis)
              keepdims = np.random.randint(0, 2)
              dat = np.random.rand(*shape) - 0.5
              if 0 == len(axes):
                  axes = tuple(range(ndim))
              else:
                  axes = tuple(axes)
              numpy_ret = numpy_reduce_func(
                  dat, axis=axes, keepdims=keepdims
              )
  
              ndarray_ret = nd_reduce_func(
                  mx.nd.array(dat), axis=axes, keepdims=keepdims
              )
              if type(ndarray_ret) is mx.ndarray.NDArray:
                  ndarray_ret = ndarray_ret.asnumpy()
              assert (ndarray_ret.shape == numpy_ret.shape) or (
                  ndarray_ret.shape == (1,) and numpy_ret.shape == ()
              ), f"nd:{ndarray_ret.shape}, numpy:{numpy_ret.shape}"
              err = np.square(ndarray_ret - numpy_ret).mean()
              assert err < 1e-4
  
      test_reduce_inner(
          lambda data, axis, keepdims: _np_reduce(
              data, axis, keepdims, np.sum
          ),
          mx.nd.sum,
      )
      test_reduce_inner(
          lambda data, axis, keepdims: _np_reduce(
              data, axis, keepdims, np.max
          ),
          mx.nd.max,
      )
      test_reduce_inner(
          lambda data, axis, keepdims: _np_reduce(
              data, axis, keepdims, np.min
          ),
          mx.nd.min,
      )
  
imports: import os
  import mxnet
  import numpy
  import pickle
label_desc: Use image node_id 19 for calling a global function with example usage: test_reduce() without return types