def METHOD_NAME(
    image: Image.Image, annotations: Tuple[Tensor, Tensor], p: float = 0.5
) -> Tuple[Image.Image, Tuple[Tensor, Tensor]]:
    """
    Performs a horizontal flip on given image and bounding boxes with probability p.
    :param image: the image to randomly flip
    :param annotations: a tuple of bounding boxes and their labels for this image
    :param p: the probability to flip with. Default is 0.5
    :return: A tuple of the randomly flipped image and annotations
    """
    if torchvision_import_error is not None:
        raise torchvision_import_error
    boxes, labels = annotations
    if random.random() < p:
        if labels.numel() > 0:
            boxes[:, [0, 2]] = 1.0 - boxes[:, [2, 0]]  # flip width dimensions
        image = torchvision_functional.hflip(image)
    return image, (boxes, labels)