def METHOD_NAME(data):
    if data.dtype == np.uint8:
        return data
    cmin = data.min()
    cmax = data.max()
    if cmin >= 0 and cmax <= 255 and data.dtype not in [np.float32, np.float16, float]:
        return data.astype(np.uint8)
    cscale = cmax - cmin
    if cscale == 0:
        cscale = 1
    scale = float(255) / cscale
    bytedata = (data - cmin) * scale
    return (bytedata.clip(0, 255) + 0.5).astype(np.uint8)