prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN 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
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `torchvision/transforms/_pil_constants.py`
  Content:
  ```
  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 FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
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"}], "after_files": [{"content": "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\nif hasattr(Image, \"Resampling\"):\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"}]}