code: def _softmax_api_helper(self, dev):
      def _run_test(dev, org_shape, axis, aft_shape):
          x_0 = np.random.random(org_shape).astype(np.float32)
          x_0 = x_0 + 1000
          x0 = tensor.Tensor(device=dev, data=x_0)
  
          # test with axis
          y0 = tensor._call_singa_func(singa_api.SoftMax, x0.data, axis)
  
          # test with numpy
          x_0 = x_0.reshape(aft_shape)
          x_0 = x_0 - np.max(x_0)
          y1 = np.divide(
              np.exp(x_0),
              np.sum(np.exp(x_0), axis=1).reshape(x_0.shape[0], 1),
          )  # 2d softmax
          y1 = y1.reshape(org_shape)
  
          np.testing.assert_array_almost_equal(tensor.to_numpy(y0), y1)
  
      _run_test(dev, [2, 2], 1, [2, 2])
      _run_test(dev, [2, 2], 0, [1, 4])
      _run_test(dev, [2, 2], -1, [2, 2])
      _run_test(dev, [2, 2], -2, [1, 4])
      _run_test(dev, [2, 2, 2], 2, [4, 2])
      _run_test(dev, [2, 2, 2], 1, [2, 4])
      _run_test(dev, [2, 2, 2], 0, [1, 8])
      _run_test(dev, [2, 2, 2], -1, [4, 2])
      _run_test(dev, [2, 2, 2], -2, [2, 4])
      _run_test(dev, [2, 2, 2], -3, [1, 8])
      _run_test(dev, [2, 2, 2, 2], 3, [8, 2])
      _run_test(dev, [2, 2, 2, 2], 2, [4, 4])
      _run_test(dev, [2, 2, 2, 2], 1, [2, 8])
      _run_test(dev, [2, 2, 2, 2], 0, [1, 16])
      _run_test(dev, [2, 2, 2, 2], -1, [8, 2])
      _run_test(dev, [2, 2, 2, 2], -2, [4, 4])
      _run_test(dev, [2, 2, 2, 2], -3, [2, 8])
      _run_test(dev, [2, 2, 2, 2], -4, [1, 16])
  
imports: from __future__ import division
  import unittest
  import math
  import numpy
  from singa import singa_wrap
  from singa import tensor
  from cuda_helper import gpu_dev, cpu_dev
label_desc: Use image node_id 3 for calling the TestAPI obj's underlying member method code with example usage: obj._softmax_api_helper(dev) without return types