def METHOD_NAME(x, max_absval, num_bits):
    y = x
    # get maximum/minimum exponent
    n1 = np.floor(np.log2(max_absval)) + (np.log2(max_absval) -
                                          np.floor(np.log2(max_absval)) >= np.log2(1.5))
    n2 = n1 + 1 - 2 ** (num_bits - 2)
    pruning_threshold = 2 ** (n2 - 1)
    # prune all small values
    y[np.abs(x) < pruning_threshold] = 0.0
    # quantize remaining values to powers of two
    _i = y != 0
    _s = np.sign(y[_i])
    _b = np.log2(np.abs(y[_i]))
    _d = np.log2(1.5)  # quantization threshold
    # _d = 0.5 use geometric mean
    # _d = np.log2(1.5) use arithmetic mean
    _e = np.floor(_b) + (_b - np.floor(_b) >= _d)
    _e = np.maximum(n2, np.minimum(n1, _e))
    y[_i] = _s * 2 ** (_e)
    return y