def rgb_to_grayscale(vid, channel=0):
    """Convert the given RGB Image Tensor to Grayscale.
    For RGB to Grayscale conversion, ITU-R 601-2 luma transform is performed which
    is L = R * 0.2989 + G * 0.5870 + B * 0.1140
    Args:
        vid (Tensor): Image to be converted to Grayscale in the form [C, N, H, W].
        channel: color channel
    Returns:
        Tensor: Grayscale video tensor [C, N, H, W].
    """
    assert vid.size(channel) == 3

    return (0.2989 * vid.select(channel,0) + 0.5870 * vid.select(channel,1) + 0.1140 * vid.select(channel,2)).to(vid.dtype)