def test_exception(self, device, dtype) -> None:
        """Test exceptions (non-tensor input, wrong JPEG quality shape, wrong img shape, and wrong QT shape.)"""
        with pytest.raises(TypeError) as errinfo:
            B = 2
            jpeg_quality = torch.randint(low=0, high=100, size=(B,), device=device, dtype=dtype)
            kornia.enhance.jpeg_codec_differentiable(1904.0, jpeg_quality)
        assert "Input input type is not a" in str(errinfo)

        with pytest.raises(TypeError) as errinfo:
            B, H, W = 2, 32, 32
            img = torch.rand(B, 3, H, W, device=device, dtype=dtype)
            kornia.enhance.jpeg_codec_differentiable(img, None)
        assert "Not a Tensor type. Got" in str(errinfo)

        with pytest.raises(TypeError) as errinfo:
            B, H, W = 2, 32, 32
            img = torch.rand(B, 3, H, W, device=device, dtype=dtype)
            jpeg_quality = torch.randint(low=0, high=100, size=(B, 3, 2, 1), device=device, dtype=dtype)
            kornia.enhance.jpeg_codec_differentiable(img, jpeg_quality)
        assert "shape must be [" in str(errinfo)

        with pytest.raises(Exception) as errinfo:
            B, H, W = 4, 32, 32
            img = torch.rand(B, 3, H, W, device=device, dtype=dtype)
            jpeg_quality = torch.randint(low=0, high=100, size=(B,), device=device, dtype=dtype)
            qt_y = torch.randint(low=1, high=255, size=(B, 7, 8), device=device, dtype=dtype)
            qt_c = torch.randint(low=1, high=255, size=(B, 8, 8), device=device, dtype=dtype)
            kornia.enhance.jpeg_codec_differentiable(img, jpeg_quality, qt_y, qt_c)
        assert "shape must be [" in str(errinfo)

        with pytest.raises(Exception) as errinfo:
            B, H, W = 4, 32, 32
            img = torch.rand(B, 3, H, W, device=device, dtype=dtype)
            jpeg_quality = torch.randint(low=0, high=100, size=(B,), device=device, dtype=dtype)
            qt_y = torch.randint(low=1, high=255, size=(B, 8, 8), device=device, dtype=dtype)
            qt_c = torch.randint(low=1, high=255, size=(B, 8, 7), device=device, dtype=dtype)
            kornia.enhance.jpeg_codec_differentiable(img, jpeg_quality, qt_y, qt_c)
        assert "shape must be [" in str(errinfo)

        with pytest.raises(Exception) as errinfo:
            B, H, W = 4, 32, 32
            img = torch.rand(B, B, 3, H, W, device=device, dtype=dtype)
            jpeg_quality = torch.randint(low=0, high=100, size=(B * B,), device=device, dtype=dtype)
            qt_y = torch.randint(low=1, high=255, size=(B * B, 8, 8), device=device, dtype=dtype)
            qt_c = torch.randint(low=1, high=255, size=(B * 2, 8, 8), device=device, dtype=dtype)
            kornia.enhance.jpeg_codec_differentiable(img, jpeg_quality, qt_y, qt_c)
        assert "Batch dimensions do not match." in str(errinfo)

        with pytest.raises(Exception) as errinfo:
            B, H, W = 4, 32, 32
            img = torch.rand(B, B, 3, H, W, device=device, dtype=dtype)
            jpeg_quality = torch.randint(low=0, high=100, size=(B * B,), device=device, dtype=dtype)
            qt_y = torch.randint(low=1, high=255, size=(B * 2, 8, 8), device=device, dtype=dtype)
            qt_c = torch.randint(low=1, high=255, size=(B * B, 8, 8), device=device, dtype=dtype)
            kornia.enhance.jpeg_codec_differentiable(img, jpeg_quality, qt_y, qt_c)
        assert "Batch dimensions do not match." in str(errinfo)

        with pytest.raises(Exception) as errinfo:
            B, H, W = 4, 32, 32
            img = torch.rand(B, B, 3, H, W, device=device, dtype=dtype)
            jpeg_quality = torch.randint(low=0, high=100, size=(B * 2,), device=device, dtype=dtype)
            qt_y = torch.randint(low=1, high=255, size=(B * B, 8, 8), device=device, dtype=dtype)
            qt_c = torch.randint(low=1, high=255, size=(B * B, 8, 8), device=device, dtype=dtype)
            kornia.enhance.jpeg_codec_differentiable(img, jpeg_quality, qt_y, qt_c)
        assert "Batch dimensions do not match." in str(errinfo)
Test exceptions (non-tensor input, wrong JPEG quality shape, wrong img shape, and wrong QT shape.)
tests/enhance/test_jpeg.py