def test_divisible_tile_size_and_stride(
    image_size: tuple,
    tile_size: tuple,
    stride: tuple,
    mode: ImageUpscaleMode,
) -> None:
    """Test non-divisible image size.

    When the image is not divisible by tile size and stride, Tiler should up
    samples the image before tiling, and downscales before untiling.
    """
    tiler = Tiler(tile_size, stride, mode=mode)
    image = torch.rand(image_size)
    tiles = tiler.tile(image)
    reconstructed_image = tiler.untile(tiles)
    assert image.shape == reconstructed_image.shape

    if mode == "padding":
        assert torch.allclose(image, reconstructed_image)
Test non-divisible image size.

    When the image is not divisible by tile size and stride, Tiler should up
    samples the image before tiling, and downscales before untiling.
    
tests/unit/data/utils/test_tiler.py