def test_stress(self, nbits, block_sizes):
        """
        As finding indices is the reverse progress of generating data from lut, we first manually
        construct indices and lut, and then generate data from lut and salt it, and finally check
        if the restored indices are identical to the original indices.
        """
        data_shape = [8, 4, 2, 3]
        lut_shape = data_shape + [2**nbits, 1]
        for idx, dim_size in enumerate(data_shape):
            if idx < len(block_sizes):
                lut_shape[idx] = 1 if block_sizes[idx] == 0 else data_shape[idx] // block_sizes[idx]

        nbits_range = types.type_mapping.builtin_to_range(types.string_to_builtin(f"uint{nbits}"))
        lut = np.arange(np.prod(lut_shape)).reshape(lut_shape).astype(np.float32)
        expected_indices = np.random.randint(
            low=nbits_range.low, high=nbits_range.high + 1, size=data_shape, dtype=np.uint8
        )

        data = constexpr_lut_to_dense.decompress(expected_indices, lut, vector_axis=None)
        # Salting the data to manually introduce numerical instability.
        data += np.random.randint(low=0, high=2, size=data.shape) * 0.01
        data -= np.random.randint(low=0, high=2, size=data.shape) * 0.01

        indices = optimize_utils.find_indices_for_lut(data, lut)

        np.testing.assert_array_equal(indices, expected_indices)
        assert (
            types.builtin_to_string(types.numpy_type_to_builtin_type(indices.dtype))
            == f"uint{nbits}"
        )

        As finding indices is the reverse progress of generating data from lut, we first manually
        construct indices and lut, and then generate data from lut and salt it, and finally check
        if the restored indices are identical to the original indices.
        
coremltools/test/optimize/test_utils.py