code: def test_calibrated_quantize_v2_bfloat16_to_int8():
      shape = rand_shape_nd(4)
      data = mx.nd.random.normal(0, 1, shape).astype("bfloat16")
      min_range = mx.nd.min(data).asscalar()
      max_range = mx.nd.max(data).asscalar()
      qdata, min_val, max_val = mx.nd.contrib.quantize_v2(
          data, "int8", min_range, max_range
      )
      data_np = data.asnumpy()
      real_range = onp.maximum(onp.abs(min_range), onp.abs(max_range))
      quantized_range = 127.0
      scale = quantized_range / real_range
      assert qdata.dtype == onp.int8
      assert min_val.dtype == onp.float32
      assert max_val.dtype == onp.float32
      assert same(min_val.asscalar(), -real_range)
      assert same(max_val.asscalar(), real_range)
      qdata_np = (
          onp.sign(data_np)
          * onp.minimum(onp.abs(data_np) * scale + 0.5, quantized_range)
      ).astype(onp.int8)
      assert_almost_equal(qdata.asnumpy(), qdata_np, atol=1)
  
imports: import os
  import mxnet
  import numpy
  from mxnet import npx
  from mxnet.util import use_np
  from mxnet.gluon.model_zoo import vision
  from mxnet.test_utils import assert_almost_equal, assert_exception, rand_ndarray, rand_shape_nd, same, DummyIter
  from common import xfail_when_nonstandard_decimal_separator
  from mxnet.io import NDArrayIter
  import unittest
  import operator
label_desc: Use image node_id 7 for calling a global function with example usage: test_calibrated_quantize_v2_bfloat16_to_int8() without return types