We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Crash for Resize augmentation on masks
### Describe the bug

The default `extra_args` added for operating on masks cause the underlying `torch.nn.functional.interpolate` to crash - bad combination of `interpolation` mode Resample.NEAREST and `align_corners=True`. Interpolate wants to not be set (None) when using nearest neighbour interpolation:

```
ValueError: align_corners option can only be set with the interpolating modes: linear | bilinear | bicubic | trilinear
```
 
### Reproduction steps

```bash
import kornia.augmentation as K
import torch
from kornia.constants import DataKey

img = torch.zeros((3,5,5))
mask = torch.zeros((1,5,5))

data_keys= [DataKey.INPUT, DataKey.MASK]
aug = K.AugmentationSequential(K.Resize(2), data_keys=data_keys)
transformed = aug(img, mask)
```


### Expected behavior

No crashes and correct computation of resize op.

### Environment

```shell
Collecting environment information...
PyTorch version: 1.10.2
Is debug build: False
CUDA used to build PyTorch: Could not collect
ROCM used to build PyTorch: N/A

OS: Ubuntu 18.04.6 LTS (x86_64)
GCC version: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Clang version: Could not collect
CMake version: Could not collect
Libc version: glibc-2.17

Python version: 3.7.15 (default, Nov 24 2022, 21:12:53)  [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-4.15.0-196-generic-x86_64-with-debian-buster-sid
Is CUDA available: False
CUDA runtime version: Could not collect
GPU models and configuration:
GPU 0: NVIDIA TITAN X (Pascal)
GPU 1: NVIDIA TITAN X (Pascal)
GPU 2: NVIDIA TITAN Xp

Nvidia driver version: 520.61.05
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip3] mypy==0.991
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.21.5
[pip3] torch==1.10.2
[pip3] torchvision==0.2.2
[conda] blas                      1.0                         mkl
[conda] cudatoolkit               10.2.89              hfd86e86_1
[conda] mkl                       2021.4.0           h06a4308_640
[conda] mkl-service               2.4.0            py37h7f8727e_0
[conda] mkl_fft                   1.3.1            py37hd3c417c_0
[conda] mkl_random                1.2.2            py37h51133e4_0
[conda] mypy                      0.991                    pypi_0    pypi
[conda] mypy-extensions           0.4.3                    pypi_0    pypi
[conda] numpy                     1.21.5           py37h6c91a56_3
[conda] numpy-base                1.21.5           py37ha15fc14_3
[conda] pytorch                   1.10.2          cpu_py37hfa7516b_0
[conda] torchvision               0.2.2                      py_3    pytorch
```


### Additional context

_No response_

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `kornia/augmentation/_2d/geometric/resize.py`
Content:
```
1 from typing import Any, Dict, Optional, Tuple, Union
2 
3 import torch
4 
5 from kornia.augmentation import random_generator as rg
6 from kornia.augmentation._2d.geometric.base import GeometricAugmentationBase2D
7 from kornia.constants import Resample
8 from kornia.core import Tensor
9 from kornia.geometry.transform import crop_by_transform_mat, get_perspective_transform, resize
10 from kornia.utils import eye_like
11 
12 
13 class Resize(GeometricAugmentationBase2D):
14     """Resize to size.
15 
16     Args:
17         size: Size (h, w) in pixels of the resized region or just one side.
18         side: Which side to resize, if size is only of type int.
19         resample: Resampling mode.
20         align_corners: interpolation flag.
21         antialias: if True, then image will be filtered with Gaussian before downscaling. No effect for upscaling.
22         keepdim: whether to keep the output shape the same as input (True) or broadcast it
23             to the batch form (False).
24     """
25 
26     def __init__(
27         self,
28         size: Union[int, Tuple[int, int]],
29         side: str = "short",
30         resample: Union[str, int, Resample] = Resample.BILINEAR.name,
31         align_corners: bool = True,
32         antialias: bool = False,
33         p: float = 1.0,
34         return_transform: Optional[bool] = None,
35         keepdim: bool = False,
36     ) -> None:
37         super().__init__(p=1.0, return_transform=return_transform, same_on_batch=True, p_batch=p, keepdim=keepdim)
38         self._param_generator = rg.ResizeGenerator(resize_to=size, side=side)
39         self.flags = dict(
40             size=size, side=side, resample=Resample.get(resample), align_corners=align_corners, antialias=antialias
41         )
42 
43     def compute_transformation(self, input: Tensor, params: Dict[str, Tensor], flags: Dict[str, Any]) -> Tensor:
44         if params["output_size"] == input.shape[-2:]:
45             return eye_like(3, input)
46 
47         transform: Tensor = get_perspective_transform(params["src"], params["dst"])
48         transform = transform.expand(input.shape[0], -1, -1)
49         return transform
50 
51     def apply_transform(
52         self, input: Tensor, params: Dict[str, Tensor], flags: Dict[str, Any], transform: Optional[Tensor] = None
53     ) -> Tensor:
54         B, C, _, _ = input.shape
55         out_size = tuple(params["output_size"][0].tolist())
56         out = torch.empty(B, C, *out_size, device=input.device, dtype=input.dtype)
57 
58         for i in range(B):
59             x1 = int(params["src"][i, 0, 0])
60             x2 = int(params["src"][i, 1, 0]) + 1
61             y1 = int(params["src"][i, 0, 1])
62             y2 = int(params["src"][i, 3, 1]) + 1
63             out[i] = resize(
64                 input[i : i + 1, :, y1:y2, x1:x2],
65                 out_size,
66                 interpolation=flags["resample"].name.lower(),
67                 align_corners=flags["align_corners"],
68                 antialias=flags["antialias"],
69             )
70         return out
71 
72     def inverse_transform(
73         self,
74         input: Tensor,
75         flags: Dict[str, Any],
76         transform: Optional[Tensor] = None,
77         size: Optional[Tuple[int, int]] = None,
78     ) -> Tensor:
79         if not isinstance(size, tuple):
80             raise TypeError(f'Expected the size be a tuple. Gotcha {type(size)}')
81 
82         if not isinstance(transform, Tensor):
83             raise TypeError(f'Expected the transform be a Tensor. Gotcha {type(transform)}')
84 
85         return crop_by_transform_mat(
86             input, transform[:, :2, :], size, flags["resample"], flags["padding_mode"], flags["align_corners"]
87         )
88 
89 
90 class LongestMaxSize(Resize):
91     """Rescale an image so that maximum side is equal to max_size, keeping the aspect ratio of the initial image.
92 
93     Args:
94         max_size: maximum size of the image after the transformation.
95     """
96 
97     def __init__(
98         self,
99         max_size: int,
100         resample: Union[str, int, Resample] = Resample.BILINEAR.name,
101         align_corners: bool = True,
102         p: float = 1.0,
103         return_transform: Optional[bool] = None,
104     ) -> None:
105         # TODO: Support max_size list input to randomly select from
106         super().__init__(
107             size=max_size,
108             side="long",
109             resample=resample,
110             return_transform=return_transform,
111             align_corners=align_corners,
112             p=p,
113         )
114 
115 
116 class SmallestMaxSize(Resize):
117     """Rescale an image so that minimum side is equal to max_size, keeping the aspect ratio of the initial image.
118 
119     Args:
120         max_size: maximum size of the image after the transformation.
121     """
122 
123     def __init__(
124         self,
125         max_size: int,
126         resample: Union[str, int, Resample] = Resample.BILINEAR.name,
127         align_corners: bool = True,
128         p: float = 1.0,
129         return_transform: Optional[bool] = None,
130     ) -> None:
131         # TODO: Support max_size list input to randomly select from
132         super().__init__(
133             size=max_size,
134             side="short",
135             resample=resample,
136             return_transform=return_transform,
137             align_corners=align_corners,
138             p=p,
139         )
140
```
--- 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()

```

diff --git a/kornia/augmentation/_2d/geometric/resize.py b/kornia/augmentation/_2d/geometric/resize.py
--- a/kornia/augmentation/_2d/geometric/resize.py
+++ b/kornia/augmentation/_2d/geometric/resize.py
@@ -64,7 +64,9 @@
                 input[i : i + 1, :, y1:y2, x1:x2],
                 out_size,
                 interpolation=flags["resample"].name.lower(),
-                align_corners=flags["align_corners"],
+                align_corners=flags["align_corners"]
+                if flags["resample"] in [Resample.BILINEAR, Resample.BICUBIC]
+                else None,
                 antialias=flags["antialias"],
             )
         return out

{"golden_diff": "diff --git a/kornia/augmentation/_2d/geometric/resize.py b/kornia/augmentation/_2d/geometric/resize.py\n--- a/kornia/augmentation/_2d/geometric/resize.py\n+++ b/kornia/augmentation/_2d/geometric/resize.py\n@@ -64,7 +64,9 @@\n                 input[i : i + 1, :, y1:y2, x1:x2],\n                 out_size,\n                 interpolation=flags[\"resample\"].name.lower(),\n-                align_corners=flags[\"align_corners\"],\n+                align_corners=flags[\"align_corners\"]\n+                if flags[\"resample\"] in [Resample.BILINEAR, Resample.BICUBIC]\n+                else None,\n                 antialias=flags[\"antialias\"],\n             )\n         return out\n", "issue": "Crash for Resize augmentation on masks\n### Describe the bug\r\n\r\nThe default `extra_args` added for operating on masks cause the underlying `torch.nn.functional.interpolate` to crash - bad combination of `interpolation` mode Resample.NEAREST and `align_corners=True`. Interpolate wants to not be set (None) when using nearest neighbour interpolation:\r\n\r\n```\r\nValueError: align_corners option can only be set with the interpolating modes: linear | bilinear | bicubic | trilinear\r\n```\r\n \r\n### Reproduction steps\r\n\r\n```bash\r\nimport kornia.augmentation as K\r\nimport torch\r\nfrom kornia.constants import DataKey\r\n\r\nimg = torch.zeros((3,5,5))\r\nmask = torch.zeros((1,5,5))\r\n\r\ndata_keys= [DataKey.INPUT, DataKey.MASK]\r\naug = K.AugmentationSequential(K.Resize(2), data_keys=data_keys)\r\ntransformed = aug(img, mask)\r\n```\r\n\r\n\r\n### Expected behavior\r\n\r\nNo crashes and correct computation of resize op.\r\n\r\n### Environment\r\n\r\n```shell\r\nCollecting environment information...\r\nPyTorch version: 1.10.2\r\nIs debug build: False\r\nCUDA used to build PyTorch: Could not collect\r\nROCM used to build PyTorch: N/A\r\n\r\nOS: Ubuntu 18.04.6 LTS (x86_64)\r\nGCC version: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0\r\nClang version: Could not collect\r\nCMake version: Could not collect\r\nLibc version: glibc-2.17\r\n\r\nPython version: 3.7.15 (default, Nov 24 2022, 21:12:53)  [GCC 11.2.0] (64-bit runtime)\r\nPython platform: Linux-4.15.0-196-generic-x86_64-with-debian-buster-sid\r\nIs CUDA available: False\r\nCUDA runtime version: Could not collect\r\nGPU models and configuration:\r\nGPU 0: NVIDIA TITAN X (Pascal)\r\nGPU 1: NVIDIA TITAN X (Pascal)\r\nGPU 2: NVIDIA TITAN Xp\r\n\r\nNvidia driver version: 520.61.05\r\ncuDNN version: Could not collect\r\nHIP runtime version: N/A\r\nMIOpen runtime version: N/A\r\n\r\nVersions of relevant libraries:\r\n[pip3] mypy==0.991\r\n[pip3] mypy-extensions==0.4.3\r\n[pip3] numpy==1.21.5\r\n[pip3] torch==1.10.2\r\n[pip3] torchvision==0.2.2\r\n[conda] blas                      1.0                         mkl\r\n[conda] cudatoolkit               10.2.89              hfd86e86_1\r\n[conda] mkl                       2021.4.0           h06a4308_640\r\n[conda] mkl-service               2.4.0            py37h7f8727e_0\r\n[conda] mkl_fft                   1.3.1            py37hd3c417c_0\r\n[conda] mkl_random                1.2.2            py37h51133e4_0\r\n[conda] mypy                      0.991                    pypi_0    pypi\r\n[conda] mypy-extensions           0.4.3                    pypi_0    pypi\r\n[conda] numpy                     1.21.5           py37h6c91a56_3\r\n[conda] numpy-base                1.21.5           py37ha15fc14_3\r\n[conda] pytorch                   1.10.2          cpu_py37hfa7516b_0\r\n[conda] torchvision               0.2.2                      py_3    pytorch\r\n```\r\n\r\n\r\n### Additional context\r\n\r\n_No response_\n", "before_files": [{"content": "from typing import Any, Dict, Optional, Tuple, Union\n\nimport torch\n\nfrom kornia.augmentation import random_generator as rg\nfrom kornia.augmentation._2d.geometric.base import GeometricAugmentationBase2D\nfrom kornia.constants import Resample\nfrom kornia.core import Tensor\nfrom kornia.geometry.transform import crop_by_transform_mat, get_perspective_transform, resize\nfrom kornia.utils import eye_like\n\n\nclass Resize(GeometricAugmentationBase2D):\n    \"\"\"Resize to size.\n\n    Args:\n        size: Size (h, w) in pixels of the resized region or just one side.\n        side: Which side to resize, if size is only of type int.\n        resample: Resampling mode.\n        align_corners: interpolation flag.\n        antialias: if True, then image will be filtered with Gaussian before downscaling. No effect for upscaling.\n        keepdim: whether to keep the output shape the same as input (True) or broadcast it\n            to the batch form (False).\n    \"\"\"\n\n    def __init__(\n        self,\n        size: Union[int, Tuple[int, int]],\n        side: str = \"short\",\n        resample: Union[str, int, Resample] = Resample.BILINEAR.name,\n        align_corners: bool = True,\n        antialias: bool = False,\n        p: float = 1.0,\n        return_transform: Optional[bool] = None,\n        keepdim: bool = False,\n    ) -> None:\n        super().__init__(p=1.0, return_transform=return_transform, same_on_batch=True, p_batch=p, keepdim=keepdim)\n        self._param_generator = rg.ResizeGenerator(resize_to=size, side=side)\n        self.flags = dict(\n            size=size, side=side, resample=Resample.get(resample), align_corners=align_corners, antialias=antialias\n        )\n\n    def compute_transformation(self, input: Tensor, params: Dict[str, Tensor], flags: Dict[str, Any]) -> Tensor:\n        if params[\"output_size\"] == input.shape[-2:]:\n            return eye_like(3, input)\n\n        transform: Tensor = get_perspective_transform(params[\"src\"], params[\"dst\"])\n        transform = transform.expand(input.shape[0], -1, -1)\n        return transform\n\n    def apply_transform(\n        self, input: Tensor, params: Dict[str, Tensor], flags: Dict[str, Any], transform: Optional[Tensor] = None\n    ) -> Tensor:\n        B, C, _, _ = input.shape\n        out_size = tuple(params[\"output_size\"][0].tolist())\n        out = torch.empty(B, C, *out_size, device=input.device, dtype=input.dtype)\n\n        for i in range(B):\n            x1 = int(params[\"src\"][i, 0, 0])\n            x2 = int(params[\"src\"][i, 1, 0]) + 1\n            y1 = int(params[\"src\"][i, 0, 1])\n            y2 = int(params[\"src\"][i, 3, 1]) + 1\n            out[i] = resize(\n                input[i : i + 1, :, y1:y2, x1:x2],\n                out_size,\n                interpolation=flags[\"resample\"].name.lower(),\n                align_corners=flags[\"align_corners\"],\n                antialias=flags[\"antialias\"],\n            )\n        return out\n\n    def inverse_transform(\n        self,\n        input: Tensor,\n        flags: Dict[str, Any],\n        transform: Optional[Tensor] = None,\n        size: Optional[Tuple[int, int]] = None,\n    ) -> Tensor:\n        if not isinstance(size, tuple):\n            raise TypeError(f'Expected the size be a tuple. Gotcha {type(size)}')\n\n        if not isinstance(transform, Tensor):\n            raise TypeError(f'Expected the transform be a Tensor. Gotcha {type(transform)}')\n\n        return crop_by_transform_mat(\n            input, transform[:, :2, :], size, flags[\"resample\"], flags[\"padding_mode\"], flags[\"align_corners\"]\n        )\n\n\nclass LongestMaxSize(Resize):\n    \"\"\"Rescale an image so that maximum side is equal to max_size, keeping the aspect ratio of the initial image.\n\n    Args:\n        max_size: maximum size of the image after the transformation.\n    \"\"\"\n\n    def __init__(\n        self,\n        max_size: int,\n        resample: Union[str, int, Resample] = Resample.BILINEAR.name,\n        align_corners: bool = True,\n        p: float = 1.0,\n        return_transform: Optional[bool] = None,\n    ) -> None:\n        # TODO: Support max_size list input to randomly select from\n        super().__init__(\n            size=max_size,\n            side=\"long\",\n            resample=resample,\n            return_transform=return_transform,\n            align_corners=align_corners,\n            p=p,\n        )\n\n\nclass SmallestMaxSize(Resize):\n    \"\"\"Rescale an image so that minimum side is equal to max_size, keeping the aspect ratio of the initial image.\n\n    Args:\n        max_size: maximum size of the image after the transformation.\n    \"\"\"\n\n    def __init__(\n        self,\n        max_size: int,\n        resample: Union[str, int, Resample] = Resample.BILINEAR.name,\n        align_corners: bool = True,\n        p: float = 1.0,\n        return_transform: Optional[bool] = None,\n    ) -> None:\n        # TODO: Support max_size list input to randomly select from\n        super().__init__(\n            size=max_size,\n            side=\"short\",\n            resample=resample,\n            return_transform=return_transform,\n            align_corners=align_corners,\n            p=p,\n        )\n", "path": "kornia/augmentation/_2d/geometric/resize.py"}], "after_files": [{"content": "from typing import Any, Dict, Optional, Tuple, Union\n\nimport torch\n\nfrom kornia.augmentation import random_generator as rg\nfrom kornia.augmentation._2d.geometric.base import GeometricAugmentationBase2D\nfrom kornia.constants import Resample\nfrom kornia.core import Tensor\nfrom kornia.geometry.transform import crop_by_transform_mat, get_perspective_transform, resize\nfrom kornia.utils import eye_like\n\n\nclass Resize(GeometricAugmentationBase2D):\n    \"\"\"Resize to size.\n\n    Args:\n        size: Size (h, w) in pixels of the resized region or just one side.\n        side: Which side to resize, if size is only of type int.\n        resample: Resampling mode.\n        align_corners: interpolation flag.\n        antialias: if True, then image will be filtered with Gaussian before downscaling. No effect for upscaling.\n        keepdim: whether to keep the output shape the same as input (True) or broadcast it\n            to the batch form (False).\n    \"\"\"\n\n    def __init__(\n        self,\n        size: Union[int, Tuple[int, int]],\n        side: str = \"short\",\n        resample: Union[str, int, Resample] = Resample.BILINEAR.name,\n        align_corners: bool = True,\n        antialias: bool = False,\n        p: float = 1.0,\n        return_transform: Optional[bool] = None,\n        keepdim: bool = False,\n    ) -> None:\n        super().__init__(p=1.0, return_transform=return_transform, same_on_batch=True, p_batch=p, keepdim=keepdim)\n        self._param_generator = rg.ResizeGenerator(resize_to=size, side=side)\n        self.flags = dict(\n            size=size, side=side, resample=Resample.get(resample), align_corners=align_corners, antialias=antialias\n        )\n\n    def compute_transformation(self, input: Tensor, params: Dict[str, Tensor], flags: Dict[str, Any]) -> Tensor:\n        if params[\"output_size\"] == input.shape[-2:]:\n            return eye_like(3, input)\n\n        transform: Tensor = get_perspective_transform(params[\"src\"], params[\"dst\"])\n        transform = transform.expand(input.shape[0], -1, -1)\n        return transform\n\n    def apply_transform(\n        self, input: Tensor, params: Dict[str, Tensor], flags: Dict[str, Any], transform: Optional[Tensor] = None\n    ) -> Tensor:\n        B, C, _, _ = input.shape\n        out_size = tuple(params[\"output_size\"][0].tolist())\n        out = torch.empty(B, C, *out_size, device=input.device, dtype=input.dtype)\n\n        for i in range(B):\n            x1 = int(params[\"src\"][i, 0, 0])\n            x2 = int(params[\"src\"][i, 1, 0]) + 1\n            y1 = int(params[\"src\"][i, 0, 1])\n            y2 = int(params[\"src\"][i, 3, 1]) + 1\n            out[i] = resize(\n                input[i : i + 1, :, y1:y2, x1:x2],\n                out_size,\n                interpolation=flags[\"resample\"].name.lower(),\n                align_corners=flags[\"align_corners\"]\n                if flags[\"resample\"] in [Resample.BILINEAR, Resample.BICUBIC]\n                else None,\n                antialias=flags[\"antialias\"],\n            )\n        return out\n\n    def inverse_transform(\n        self,\n        input: Tensor,\n        flags: Dict[str, Any],\n        transform: Optional[Tensor] = None,\n        size: Optional[Tuple[int, int]] = None,\n    ) -> Tensor:\n        if not isinstance(size, tuple):\n            raise TypeError(f'Expected the size be a tuple. Gotcha {type(size)}')\n\n        if not isinstance(transform, Tensor):\n            raise TypeError(f'Expected the transform be a Tensor. Gotcha {type(transform)}')\n\n        return crop_by_transform_mat(\n            input, transform[:, :2, :], size, flags[\"resample\"], flags[\"padding_mode\"], flags[\"align_corners\"]\n        )\n\n\nclass LongestMaxSize(Resize):\n    \"\"\"Rescale an image so that maximum side is equal to max_size, keeping the aspect ratio of the initial image.\n\n    Args:\n        max_size: maximum size of the image after the transformation.\n    \"\"\"\n\n    def __init__(\n        self,\n        max_size: int,\n        resample: Union[str, int, Resample] = Resample.BILINEAR.name,\n        align_corners: bool = True,\n        p: float = 1.0,\n        return_transform: Optional[bool] = None,\n    ) -> None:\n        # TODO: Support max_size list input to randomly select from\n        super().__init__(\n            size=max_size,\n            side=\"long\",\n            resample=resample,\n            return_transform=return_transform,\n            align_corners=align_corners,\n            p=p,\n        )\n\n\nclass SmallestMaxSize(Resize):\n    \"\"\"Rescale an image so that minimum side is equal to max_size, keeping the aspect ratio of the initial image.\n\n    Args:\n        max_size: maximum size of the image after the transformation.\n    \"\"\"\n\n    def __init__(\n        self,\n        max_size: int,\n        resample: Union[str, int, Resample] = Resample.BILINEAR.name,\n        align_corners: bool = True,\n        p: float = 1.0,\n        return_transform: Optional[bool] = None,\n    ) -> None:\n        # TODO: Support max_size list input to randomly select from\n        super().__init__(\n            size=max_size,\n            side=\"short\",\n            resample=resample,\n            return_transform=return_transform,\n            align_corners=align_corners,\n            p=p,\n        )\n", "path": "kornia/augmentation/_2d/geometric/resize.py"}]}