def METHOD_NAME(im, saturation_lower, saturation_upper, is_rgb=False):
    if is_rgb:
        gray_scale = np.array([[[0.299, 0.587, 0.114]]], dtype=np.float32)
    else:
        gray_scale = np.array([[[0.114, 0.587, 0.299]]], dtype=np.float32)
    delta = np.random.uniform(saturation_lower, saturation_upper)
    gray = im * gray_scale
    gray = gray.sum(axis=2, keepdims=True)
    gray *= (1.0 - delta)
    im *= delta
    im += gray
    return im