def test_quant_lut(
        self, compute_unit, backend, nbits, block_sizes, vector_size, lut_dtype, quant_dtype
    ):
        """
        Test lut with quantized (int8) entries, which is represented as
            lut(int8) -> constexpr_blockwise_shift_scale -> lut(fp) \
                                                                constexpr_lut_to_dense -> dense(fp)
                                                         indices /
        """

        indices_shape = (4, 8, 16, 8)
        builtin_dtype = types.string_to_builtin(f"uint{nbits}")
        np_dtype = types.nptype_from_builtin(builtin_dtype)
        indices = np.random.randint(low=0, high=2**nbits, size=indices_shape).astype(np_dtype)

        lut_np_dtype = types.nptype_from_builtin(types.string_to_builtin(lut_dtype))
        lut_shape = _infer_lut_shape(indices_shape, block_sizes, nbits, vector_size)
        vector_axis = 0 if vector_size > 1 else None

        quant_builtin_dtype = types.string_to_builtin(quant_dtype)
        quant_np_dtype = types.nptype_from_builtin(quant_builtin_dtype)
        quant_data_range = types.type_mapping.builtin_to_range(quant_builtin_dtype)
        quantized_data = np.random.randint(
            low=quant_data_range.low, high=quant_data_range.high + 1, size=lut_shape
        ).astype(quant_np_dtype)
        scale_shape = tuple([1] * len(lut_shape))
        scale = np.array([2.0]).reshape(scale_shape).astype(lut_np_dtype)
        offset = np.array([3]).reshape(scale_shape).astype(quant_np_dtype)

        def build(x):
            lut = mb.constexpr_blockwise_shift_scale(
                data=quantized_data,
                scale=scale,
                offset=offset,
            )
            output = mb.constexpr_lut_to_dense(
                indices=indices,
                lut=lut,
                vector_axis=vector_axis,
            )
            x, output = promote_input_dtypes([x, output])
            return mb.add(x=x, y=output)

        output_shape = list(indices.shape)
        if vector_size > 1:
            output_shape[vector_axis] *= vector_size
        x_val = np.ones(output_shape).astype(np.float32)
        input_placeholders = {"x": mb.placeholder(shape=x_val.shape)}
        lut = constexpr_blockwise_shift_scale.decompress(quantized_data, scale, offset)
        expected_output = (
            constexpr_lut_to_dense.decompress(indices, lut, vector_axis=vector_axis) + 1
        )

        run_compare_builder(
            build,
            input_placeholders,
            input_values={"x": x_val},
            expected_output_types=expected_output.shape + (types.fp32,),
            expected_outputs=expected_output,
            compute_unit=compute_unit,
            backend=backend,
        )

        Test lut with quantized (int8) entries, which is represented as
            lut(int8) -> constexpr_blockwise_shift_scale -> lut(fp)                                                                 constexpr_lut_to_dense -> dense(fp)
                                                         indices /
        
coremltools/converters/mil/mil/ops/tests/iOS18/test_compression.py