prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  PIL version check for enum change appears to break SIMD versions
  ### 🐛 Describe the bug
  
  This change appears to break current Pillow-SIMD version #5898 
  
  ```
      if tuple(int(part) for part in PIL.__version__.split(".")) >= (9, 1):
    File "/home/.../lib/python3.10/site-packages/torchvision/transforms/_pil_constants.py", line 7, in <genexpr>
      if tuple(int(part) for part in PIL.__version__.split(".")) >= (9, 1):
  ValueError: invalid literal for int() with base 10: 'post1'
  ```
  
  Amusingly enough, I warned against this approach in a users PR in `timm` https://github.com/rwightman/pytorch-image-models/pull/1256
  
  Would be nice to have it fixed before 1.12 is finalized, I just hit this trying out the RC
  
  ### Versions
  
  PT 1.12 RC, TV 0.13.0
  
  </issue>
  <code>
  [start of torchvision/transforms/_pil_constants.py]
  1 import PIL
  2 from PIL import Image
  3 
  4 # See https://pillow.readthedocs.io/en/stable/releasenotes/9.1.0.html#deprecations
  5 # TODO: Remove this file once PIL minimal version is >= 9.1
  6 
  7 if tuple(int(part) for part in PIL.__version__.split(".")) >= (9, 1):
  8     BICUBIC = Image.Resampling.BICUBIC
  9     BILINEAR = Image.Resampling.BILINEAR
  10     LINEAR = Image.Resampling.BILINEAR
  11     NEAREST = Image.Resampling.NEAREST
  12 
  13     AFFINE = Image.Transform.AFFINE
  14     FLIP_LEFT_RIGHT = Image.Transpose.FLIP_LEFT_RIGHT
  15     FLIP_TOP_BOTTOM = Image.Transpose.FLIP_TOP_BOTTOM
  16     PERSPECTIVE = Image.Transform.PERSPECTIVE
  17 else:
  18     BICUBIC = Image.BICUBIC
  19     BILINEAR = Image.BILINEAR
  20     NEAREST = Image.NEAREST
  21     LINEAR = Image.LINEAR
  22 
  23     AFFINE = Image.AFFINE
  24     FLIP_LEFT_RIGHT = Image.FLIP_LEFT_RIGHT
  25     FLIP_TOP_BOTTOM = Image.FLIP_TOP_BOTTOM
  26     PERSPECTIVE = Image.PERSPECTIVE
  27
  [end of torchvision/transforms/_pil_constants.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/torchvision/transforms/_pil_constants.py b/torchvision/transforms/_pil_constants.py
  --- a/torchvision/transforms/_pil_constants.py
  +++ b/torchvision/transforms/_pil_constants.py
  @@ -1,10 +1,9 @@
  -import PIL
   from PIL import Image
   
   # See https://pillow.readthedocs.io/en/stable/releasenotes/9.1.0.html#deprecations
   # TODO: Remove this file once PIL minimal version is >= 9.1
   
  -if tuple(int(part) for part in PIL.__version__.split(".")) >= (9, 1):
  +if hasattr(Image, "Resampling"):
       BICUBIC = Image.Resampling.BICUBIC
       BILINEAR = Image.Resampling.BILINEAR
       LINEAR = Image.Resampling.BILINEAR
  
verification_info: {"golden_diff": "diff --git a/torchvision/transforms/_pil_constants.py b/torchvision/transforms/_pil_constants.py\n--- a/torchvision/transforms/_pil_constants.py\n+++ b/torchvision/transforms/_pil_constants.py\n@@ -1,10 +1,9 @@\n-import PIL\n from PIL import Image\n \n # See https://pillow.readthedocs.io/en/stable/releasenotes/9.1.0.html#deprecations\n # TODO: Remove this file once PIL minimal version is >= 9.1\n \n-if tuple(int(part) for part in PIL.__version__.split(\".\")) >= (9, 1):\n+if hasattr(Image, \"Resampling\"):\n     BICUBIC = Image.Resampling.BICUBIC\n     BILINEAR = Image.Resampling.BILINEAR\n     LINEAR = Image.Resampling.BILINEAR\n", "issue": "PIL version check for enum change appears to break SIMD versions\n### \ud83d\udc1b Describe the bug\n\nThis change appears to break current Pillow-SIMD version #5898 \r\n\r\n```\r\n    if tuple(int(part) for part in PIL.__version__.split(\".\")) >= (9, 1):\r\n  File \"/home/.../lib/python3.10/site-packages/torchvision/transforms/_pil_constants.py\", line 7, in <genexpr>\r\n    if tuple(int(part) for part in PIL.__version__.split(\".\")) >= (9, 1):\r\nValueError: invalid literal for int() with base 10: 'post1'\r\n```\r\n\r\nAmusingly enough, I warned against this approach in a users PR in `timm` https://github.com/rwightman/pytorch-image-models/pull/1256\r\n\r\nWould be nice to have it fixed before 1.12 is finalized, I just hit this trying out the RC\n\n### Versions\n\nPT 1.12 RC, TV 0.13.0\n", "before_files": [{"content": "import PIL\nfrom PIL import Image\n\n# See https://pillow.readthedocs.io/en/stable/releasenotes/9.1.0.html#deprecations\n# TODO: Remove this file once PIL minimal version is >= 9.1\n\nif tuple(int(part) for part in PIL.__version__.split(\".\")) >= (9, 1):\n    BICUBIC = Image.Resampling.BICUBIC\n    BILINEAR = Image.Resampling.BILINEAR\n    LINEAR = Image.Resampling.BILINEAR\n    NEAREST = Image.Resampling.NEAREST\n\n    AFFINE = Image.Transform.AFFINE\n    FLIP_LEFT_RIGHT = Image.Transpose.FLIP_LEFT_RIGHT\n    FLIP_TOP_BOTTOM = Image.Transpose.FLIP_TOP_BOTTOM\n    PERSPECTIVE = Image.Transform.PERSPECTIVE\nelse:\n    BICUBIC = Image.BICUBIC\n    BILINEAR = Image.BILINEAR\n    NEAREST = Image.NEAREST\n    LINEAR = Image.LINEAR\n\n    AFFINE = Image.AFFINE\n    FLIP_LEFT_RIGHT = Image.FLIP_LEFT_RIGHT\n    FLIP_TOP_BOTTOM = Image.FLIP_TOP_BOTTOM\n    PERSPECTIVE = Image.PERSPECTIVE\n", "path": "torchvision/transforms/_pil_constants.py"}]}