def scale_boxes(boxes: torch.Tensor, image_size: torch.Size, new_size: torch.Size) -> torch.Tensor:
    """Scale bounding box coordinates to a new image size.

    Args:
        boxes: Boxes of shape ``(N, 4)`` in ``(x1, y1, x2, y2)`` format
        image_size: Original image size the boxes were computed for
        new_size: Target image size to scale boxes to

    Returns:
        Scaled boxes of shape ``(N, 4)`` in ``(x1, y1, x2, y2)`` format

    Examples:
        >>> boxes = torch.tensor([[10, 15, 20, 25]])
        >>> scaled = scale_boxes(boxes, (32, 32), (64, 64))
        >>> scaled
        tensor([[20., 30., 40., 50.]])
    """
    scale = torch.Tensor([*new_size]) / torch.Tensor([*image_size])
    return boxes * scale.repeat(2).to(boxes.device)
Scale bounding box coordinates to a new image size.

    Args:
        boxes: Boxes of shape ``(N, 4)`` in ``(x1, y1, x2, y2)`` format
        image_size: Original image size the boxes were computed for
        new_size: Target image size to scale boxes to

    Returns:
        Scaled boxes of shape ``(N, 4)`` in ``(x1, y1, x2, y2)`` format

    Examples:
        >>> boxes = torch.tensor([[10, 15, 20, 25]])
        >>> scaled = scale_boxes(boxes, (32, 32), (64, 64))
        >>> scaled
        tensor([[20., 30., 40., 50.]])
    
src/anomalib/data/utils/boxes.py