Quantize the weight blob

    :param wp: numpy.array
        Weight parameters
    :param nbits: int
        Number of bits
    :param qm:
        Quantization mode
    :param lut_function: (``callable function``)
        Python callable representing a look-up table

    Returns
    -------
    scale: numpy.array
        Per-channel scale
    bias: numpy.array
        Per-channel bias
    lut: numpy.array
        Lookup table
    quantized_wp: numpy.array
        Quantized weight of same shape as wp, with dtype numpy.uint8

def _quantize_wp(wp, nbits, qm, axis=0, **kwargs):
    """
    Quantize the weight blob

    :param wp: numpy.array
        Weight parameters
    :param nbits: int
        Number of bits
    :param qm:
        Quantization mode
    :param lut_function: (``callable function``)
        Python callable representing a look-up table

    Returns
    -------
    scale: numpy.array
        Per-channel scale
    bias: numpy.array
        Per-channel bias
    lut: numpy.array
        Lookup table
    quantized_wp: numpy.array
        Quantized weight of same shape as wp, with dtype numpy.uint8
    """

    scale = bias = lut = None
    # Linear Quantization
    if qm == _QUANTIZATION_MODE_LINEAR_QUANTIZATION:
        qw, scale, bias = _quantize_channelwise_linear(wp, nbits, axis)
    # Lookup tables
    elif qm == _QUANTIZATION_MODE_LOOKUP_TABLE_KMEANS:
        lut, qw = _get_kmeans_lookup_table_and_weight(nbits, wp)
    elif qm == _QUANTIZATION_MODE_CUSTOM_LOOKUP_TABLE:
        if 'lut_function' not in kwargs.keys():
            raise Exception('Custom lookup table quantization mode '
                            'selected but no lookup table function passed')
        lut_function = kwargs['lut_function']
        if not callable(lut_function):
            raise Exception('Argument for Lookup Table passed in but is '
                            'not callable')
        try:
            lut, qw = lut_function(nbits, wp)
        except Exception as e:
            raise Exception('{}\nCall to Lookup Table function failed'
                            .format(e.message))
    elif qm == _QUANTIZATION_MODE_LOOKUP_TABLE_LINEAR:
        lut, qw = _get_linear_lookup_table_and_weight(nbits, wp)
    else:
        raise NotImplementedError('Quantization method "{}" not supported'.format(qm))

    quantized_wp = _np.uint8(qw)
    return scale, bias, lut, quantized_wp