def test_builder_to_backend_stress(
        self, compute_unit, backend, dtype, block_sizes, has_offset, sparse_ratio
    ):
        """
        Use constexpr_sparse_blockwise_shift_scale op's value inference to check backends outputs.
        """
        quantized_data_shape = (4, 8, 16, 8)
        builtin_dtype = types.string_to_builtin(dtype)
        np_dtype = types.nptype_from_builtin(builtin_dtype)

        data_mask = np.random.choice(
            [0, 1], size=quantized_data_shape, p=[sparse_ratio, 1.0 - sparse_ratio]
        ).astype(types.np_uint1_dtype)
        data_nonzero_element_num = int(np.sum(data_mask))

        if types.is_int(builtin_dtype):
            data_range = types.type_mapping.builtin_to_range(builtin_dtype)
            quantized_data = np.random.randint(
                low=data_range.low, high=data_range.high + 1, size=data_nonzero_element_num
            ).astype(np_dtype)
        else:
            quantized_data = np.random.rand(data_nonzero_element_num).astype(np_dtype)

        scale_shape = [
            1 if block_sizes[axis] == 0 else dim_size // block_sizes[axis]
            for axis, dim_size in enumerate(quantized_data_shape)
        ]
        scale = np.random.rand(*scale_shape)
        offset = None
        if has_offset:
            if types.is_int(builtin_dtype):
                offset = np.random.randint(
                    low=data_range.low, high=data_range.high + 1, size=scale.shape
                ).astype(np_dtype)
            else:
                offset = np.random.rand(*scale.shape).astype(np_dtype)

        def build(x):
            output_mask, output_nonzero_data = mb.constexpr_sparse_blockwise_shift_scale(
                data_mask=data_mask,
                nonzero_data=quantized_data,
                scale=scale,
                offset=offset,
            )
            return mb.add(x=x, y=output_nonzero_data)

        x_val = np.ones_like(quantized_data).astype(np.float32)
        input_placeholders = {"x": mb.placeholder(shape=x_val.shape)}
        expected_output = (
            constexpr_sparse_blockwise_shift_scale.decompress(
                data_mask, quantized_data, scale, offset
            )[1]
            + 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,
        )

        Use constexpr_sparse_blockwise_shift_scale op's value inference to check backends outputs.
        
coremltools/converters/mil/mil/ops/tests/iOS18/test_compression.py