def test_linear_quantizer_compression_blockwise_integer(self, nbits, signed, block_size, mode):
        """
        We use int input because after rounding the dequantized data the numerical loss is less
        critical when comparing it to the original data.
        """
        input_shape = (32, 64)
        nbits_range_max = 2 ** (nbits - 1) - 1
        nbits_range_min = -nbits_range_max
        original_data = np.random.randint(nbits_range_min, nbits_range_max, input_shape).astype(
            np.float32
        )
        compressed_params = quantization.linear_quantize_weights.blockwise_compress(
            original_data, nbits, mode, signed, block_sizes=[1, block_size]
        )
        decompressed_val = quantization.linear_quantize_weights.decompress(compressed_params)
        decompressed_val = np.round(decompressed_val).astype(original_data.dtype)

        assert np.sum(original_data != decompressed_val) / original_data.size < 0.03
        assert np.all(np.abs(original_data - decompressed_val) <= 1)

        We use int input because after rounding the dequantized data the numerical loss is less
        critical when comparing it to the original data.
        
coremltools/test/optimize/coreml/test_passes.py