code: def do_test_bounded(
      self, nbin, n, shift=2, minv=500, rspan=None, seed=None
  ):
      if seed is None:
          for run in range(50):
              self.do_test_bounded(
                  nbin, n, shift, minv, rspan, seed=123 + run
              )
          return
  
      if rspan is None:
          rmin, rmax = 0, nbin * 6
      else:
          rmin, rmax = rspan
  
      rs = np.random.RandomState(seed)
      tab = rs.randint(rmin, rmax, size=n).astype("uint16")
      bc = np.bincount(tab, minlength=65536)
  
      binsize = 1 << shift
      ref_histogram = bc[minv : minv + binsize * nbin]
  
      def pad_and_reshape(x, m, n):
          xout = np.zeros(m * n, dtype=x.dtype)
          xout[: x.size] = x
          return xout.reshape(m, n)
  
      ref_histogram = pad_and_reshape(ref_histogram, nbin, binsize)
      ref_histogram = ref_histogram.sum(1)
  
      tab_a = faiss.AlignedTableUint16()
      faiss.copy_array_to_AlignedTable(tab, tab_a)
      sp = faiss.swig_ptr
  
      hist = np.zeros(nbin, "int32")
      if nbin == 8:
          faiss.simd_histogram_8(tab_a.get(), n, minv, shift, sp(hist))
      elif nbin == 16:
          faiss.simd_histogram_16(tab_a.get(), n, minv, shift, sp(hist))
      else:
          raise AssertionError()
  
      np.testing.assert_array_equal(hist, ref_histogram)
  
imports: import numpy
  import faiss
  import unittest
label_desc: Use image node_id 6 for calling the TestHistograms obj's underlying member method code with example usage: obj.do_test_bounded(nbin, n, shift, minv, rspan, seed) and returns: xout