code: def test_get_optimal_thresholds():
      # Given an ndarray with elements following a uniform distribution, the optimal threshold
      # for quantizing the ndarray should be either abs(min(nd)) or abs(max(nd)).
      def get_threshold(nd):
          min_nd = mx.nd.min(nd)
          max_nd = mx.nd.max(nd)
          return mx.nd.maximum(
              mx.nd.abs(min_nd), mx.nd.abs(max_nd)
          ).asnumpy()
  
      for dtype in ["uint8", "int8", "auto"]:
          nd = mx.nd.uniform(
              low=-10.532,
              high=11.3432,
              shape=(8, 3, 23, 23),
              dtype=onp.float64,
          )
          expected_threshold = get_threshold(nd)
          arr = nd.asnumpy()
          min_range = onp.min(arr)
          max_range = onp.max(arr)
          th = max(abs(min_range), abs(max_range))
          hist, hist_edges = onp.histogram(
              arr, bins=8001, range=(-th, th)
          )
          hist_dict = {
              "layer1": (hist, hist_edges, min_range, max_range, th)
          }
          min_max_dict = mx.contrib.quant._LayerHistogramCollector.get_optimal_thresholds(
              hist_dict, dtype
          )
          assert "layer1" in min_max_dict
          assert_almost_equal(
              onp.array([min_max_dict["layer1"][1]]),
              expected_threshold,
              rtol=1e-2,
              atol=1e-4,
          )
  
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 28 for calling a global function with example usage: test_get_optimal_thresholds() and returns: mx