def to_tiles(img, size):
    """
    Tiles an image.

    Arguments:
        img {torch.Tensor} -- image tensor [shape = (H, W, 3)]
        size {int} -- tile size in pixels

    Returns:
        torch.Tensor -- tiled images tensor [shape = (H //  size, W // size, size, size, 3)]
    """

    return img.unfold(0, size, size).unfold(1, size, size).unfold(2, 3, 3).squeeze()