code: def test_contrib_intgemm_prepare_data(shape, max_quant):
      if "intgemm_prepare_data" not in dir(mx.nd.contrib):
          return
      m = mx.nd.random_uniform(low=-3.0, high=3.0, shape=shape)
      scaled = m * 127.0 / max_quant
      # Rounding 0.5 can go up or down.  Move values away from 0.5.
      too_close = mx.nd.abs(mx.nd.round(scaled) - scaled) > 0.45
      # Add 0.2 in scaled space so (0.45, 0.55) maps to (0.65, 0.75) which will round consistently.
      m += max_quant / 127.0 * 0.2 * too_close
  
      # Reference: scale and round
      ref = mx.nd.round(m * 127.0 / max_quant)
      # Clip to [-127, 127].  Because otherwise e.g. -129 casts to +127.
      ref = mx.nd.broadcast_maximum(ref, mx.nd.array([-127.0]))
      ref = mx.nd.broadcast_minimum(ref, mx.nd.array([127.0]))
      # Reference: cast to int8
      ref = mx.nd.cast(ref, dtype="int8")
      # Reference: ban -128
      ref = mx.nd.broadcast_maximum(
          ref, mx.nd.array([-127], dtype="int8")
      )
  
      test = mx.nd.contrib.intgemm_prepare_data(
          m, mx.nd.array([max_quant])
      )
      assert same(test, ref)
      test = npx.intgemm_prepare_data(
          m.as_np_ndarray(), np.array([max_quant])
      )
      assert same(test, ref.as_np_ndarray())
  
file_path: mxnet/tests/python/unittest/test_contrib_intgemm.py
imports: import mxnet
  from mxnet import np, npx
  from mxnet.test_utils import same, use_np, assert_almost_equal
  import random
  import pytest
label_desc: Use image node_id 2 for calling a global function with example usage: test_contrib_intgemm_prepare_data(shape, max_quant) without return types