def forward(
        self, img: Image.Image, location: Location
    ) -> Tuple[Image.Image, Location]:
        """Vertical flip image.

        Vertically flip the given image randomly with a given probability and
        return both the resulting image and the location.

        Args:
            img (PIL Image or Tensor): Image to be flipped..
            Location: Location object linked to the image
        Returns:
            PIL Image or Tensor: Randomly flipped image
            Location: Location object with updated location.vertical_flip parameter
        """

        if torch.rand(1) < self.p:
            img = F.vflip(img)
            location.vertical_flip = True
        return img, location
Vertical flip image.

        Vertically flip the given image randomly with a given probability and
        return both the resulting image and the location.

        Args:
            img (PIL Image or Tensor): Image to be flipped..
            Location: Location object linked to the image
        Returns:
            PIL Image or Tensor: Randomly flipped image
            Location: Location object with updated location.vertical_flip parameter
        
lightly/transforms/random_crop_and_flip_with_grid.py