def blockwise_compress_by_dtype(
        cls,
        original_data: np.ndarray,
        dtype: Union["types", str],
        mode: str,
        block_sizes: List[int],
    ) -> Optional["optimize_utils.QuantParams"]:
        """
        Similar to `blockwise_compress`, but use `dtype` to specify quant dtype.
        """
        if isinstance(dtype, str):
            dtype = types.string_to_builtin(dtype)

        result = optimize_utils.compute_qparams_by_dtype(
            original_data,
            dtype,
            mode,
            block_sizes,
        )

        if result is None:
            return None

        quantized_data, scale, zero_point = result
        return optimize_utils.QuantParams(
            data=quantized_data,
            scale=scale,
            offset=zero_point,
            nbits=np.uint8(dtype.get_bitwidth()),
        )

        Similar to `blockwise_compress`, but use `dtype` to specify quant dtype.
        
coremltools/optimize/coreml/_quantization_passes.py