code: def preprocess_arg_reduction(x, axes):
      r"""
      Transpose and reshape the input numpy.ndarray x for 2D shape
      (outer, reduction_axes). This is required because numpy cannot calculate
      argmmin/argmax for multi-dimension.
  
      Args:
          x (numpy.ndarray): Input array.
          axis (:obj:`tuple` of :obj:`int`): Argmax/argmin along these axes.
      """
      shape = np.array(x.shape)
      outer_axes = list(np.delete(np.arange(x.ndim), axes))
      outer_size = np.prod(shape[outer_axes])
      reduction_axes = list(axes)
      reduction_size = np.prod(shape[reduction_axes])
      transpose_axes = outer_axes + reduction_axes
      argmax_shape = [outer_size, reduction_size]
      return x.transpose(transpose_axes).reshape(*argmax_shape)
  
file_path: nnabla/python/test/function/test_reduction.py
imports: import pytest
  import numpy
  import nnabla
  import nnabla.functions
  from nnabla.testing import assert_allclose
  from nbla_test_utils import function_tester, list_context, list_ctx_and_func_name
label_desc: Use image node_id 4 for calling a global function with example usage: preprocess_arg_reduction(x, axes) and returns: x