import torch


def vflip(input):
    """
        Vertically flip a tensor image or a batch of tensor images.
    """

    h = input.shape[-2]
    return input[..., torch.arange(h - 1, -1, -1, device=input.device), :]