def quantize_weight(
    weight: np.ndarray,
    axes: Tuple[int, ...],
    nbits: int,
    signed: bool,
    quantization_mode: str,
    dtype: np.dtype,
) -> Tuple[np.ndarray, np.ndarray, Optional[np.ndarray]]:
    """Get quantized data along with metadata (scale, zero_point)."""
    builtin_dtype = types.get_nbits_int_builtin_type(nbits, signed)
    quantized_data, scale, zero_point = quantize_weight_by_dtype(
        weight, axes, builtin_dtype, quantization_mode
    )
    quantized_data = quantized_data.astype(dtype)
    if zero_point is not None:
        zero_point = zero_point.astype(dtype)
    return quantized_data, scale, zero_point
Get quantized data along with metadata (scale, zero_point).
coremltools/optimize/_utils.py