We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
No automatic `nearest` interpolation for masks in `RandomElasticTransform`
### Describe the bug

Usually, the data type `DataKey.MASK` uses the `nearest` interpolation method to preserve label index values (e.g. when using `RandomAffine`). However, this does not work for the `RandomElasticTransform` augmentation since the corresponding parameter is named `mode` and not `resample`. Hence the default argument to `AugmentationSequential`
```python
extra_args={DataKey.MASK: dict(resample=Resample.NEAREST, align_corners=True)}
```
does not trigger the `nearest` interpolation mode.

### Reproduction steps

Here is an example reproducing the issue of the current default interpolation for mask input types:
```python
import torch
import kornia.augmentation as K
features = torch.rand(1, 1, 4, 4)
labels = torch.ones(1, 1, 4, 4, dtype=torch.float32) * 10
labels[:, :, :, :2] = 0
labels[:, :, :2, :] = 0
# tensor([[[[ 0.,  0.,  0.,  0.],
#           [ 0.,  0.,  0.,  0.],
#           [ 0.,  0., 10., 10.],
#           [ 0.,  0., 10., 10.]]]])

compose = K.AugmentationSequential(K.RandomElasticTransform(alpha=(10, 10)))
torch.manual_seed(0)
compose(features, labels, data_keys=["input", "mask"])[1]
# tensor([[[[0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00],
#           [0.0000e+00, 0.0000e+00, 4.4417e-03, 4.3297e-03],
#           [0.0000e+00, 0.0000e+00, 9.8832e+00, 1.0000e+01],
#           [0.0000e+00, 0.0000e+00, 9.8833e+00, 1.0000e+01]]]])
```


### Expected behavior

The default behavior for the elastic transformation should be similar to the other transformations, i.e. `nearest` interpolation for mask types.

### Environment
- PyTorch Version (e.g., 1.0): 1.13
- OS (e.g., Linux): Linux
- How you installed PyTorch (`conda`, `pip`, source): pip
- Build command you used (if compiling from source):
- Python version: 3.10.4
- CUDA/cuDNN version: 11.7
- GPU models and configuration: 3090
- Any other relevant information:


### Additional context

Current workaround for this issue is to manually set the interpolation mode:
```python
compose = K.AugmentationSequential(*transforms, extra_args={DataKey.MASK: dict(resample=Resample.NEAREST, align_corners=True, mode="nearest")})
```

One option would be to rename the `mode` parameter to `resample`, than the default mask handling triggers as well. This would be a breaking change but I see that elastic transformation might get some exciting new functionality in the future anyway (issue #994) so this could be a combined change.

--- 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/elastic_transform.py`
Content:
```
1 from typing import Any, Dict, Optional, Tuple
2 
3 import torch
4 from torch import Tensor
5 
6 from kornia.augmentation._2d.geometric.base import GeometricAugmentationBase2D
7 from kornia.geometry.transform import elastic_transform2d
8 
9 
10 class RandomElasticTransform(GeometricAugmentationBase2D):
11     r"""Add random elastic transformation to a tensor image.
12 
13     .. image:: _static/img/RandomElasticTransform.png
14 
15     Args:
16         kernel_size: the size of the Gaussian kernel.
17         sigma: The standard deviation of the Gaussian in the y and x directions,
18           respectively. Larger sigma results in smaller pixel displacements.
19         alpha: The scaling factor that controls the intensity of the deformation
20           in the y and x directions, respectively.
21         align_corners: Interpolation flag used by `grid_sample`.
22         mode: Interpolation mode used by `grid_sample`. Either 'bilinear' or 'nearest'.
23         padding_mode: The padding used by ```grid_sample```. Either 'zeros', 'border' or 'refection'.
24         same_on_batch: apply the same transformation across the batch.
25         p: probability of applying the transformation.
26         keepdim: whether to keep the output shape the same as input (True) or broadcast it
27             to the batch form (False).
28 
29     .. note::
30         This function internally uses :func:`kornia.geometry.transform.elastic_transform2d`.
31 
32     Examples:
33         >>> import torch
34         >>> img = torch.ones(1, 1, 2, 2)
35         >>> out = RandomElasticTransform()(img)
36         >>> out.shape
37         torch.Size([1, 1, 2, 2])
38 
39     To apply the exact augmenation again, you may take the advantage of the previous parameter state:
40         >>> input = torch.randn(1, 3, 32, 32)
41         >>> aug = RandomElasticTransform(p=1.)
42         >>> (aug(input) == aug(input, params=aug._params)).all()
43         tensor(True)
44     """
45 
46     def __init__(
47         self,
48         kernel_size: Tuple[int, int] = (63, 63),
49         sigma: Tuple[float, float] = (32.0, 32.0),
50         alpha: Tuple[float, float] = (1.0, 1.0),
51         align_corners: bool = False,
52         mode: str = "bilinear",
53         padding_mode: str = "zeros",
54         same_on_batch: bool = False,
55         p: float = 0.5,
56         keepdim: bool = False,
57         return_transform: Optional[bool] = None,
58     ) -> None:
59         super().__init__(
60             p=p, return_transform=return_transform, same_on_batch=same_on_batch, p_batch=1.0, keepdim=keepdim
61         )
62         self.flags = dict(
63             kernel_size=kernel_size,
64             sigma=sigma,
65             alpha=alpha,
66             align_corners=align_corners,
67             mode=mode,
68             padding_mode=padding_mode,
69         )
70 
71     def generate_parameters(self, shape: torch.Size) -> Dict[str, Tensor]:
72         B, _, H, W = shape
73         if self.same_on_batch:
74             noise = torch.rand(1, 2, H, W, device=self.device, dtype=self.dtype).repeat(B, 1, 1, 1)
75         else:
76             noise = torch.rand(B, 2, H, W, device=self.device, dtype=self.dtype)
77         return dict(noise=noise * 2 - 1)
78 
79     # TODO: It is incorrect to return identity
80     def compute_transformation(self, input: Tensor, params: Dict[str, Tensor], flags: Dict[str, Any]) -> Tensor:
81         return self.identity_matrix(input)
82 
83     def apply_transform(
84         self, input: Tensor, params: Dict[str, Tensor], flags: Dict[str, Any], transform: Optional[Tensor] = None
85     ) -> Tensor:
86         return elastic_transform2d(
87             input,
88             params["noise"].to(input),
89             flags["kernel_size"],
90             flags["sigma"],
91             flags["alpha"],
92             flags["align_corners"],
93             flags["mode"],
94             flags["padding_mode"],
95         )
96
```
--- 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/elastic_transform.py b/kornia/augmentation/_2d/geometric/elastic_transform.py
--- a/kornia/augmentation/_2d/geometric/elastic_transform.py
+++ b/kornia/augmentation/_2d/geometric/elastic_transform.py
@@ -1,9 +1,11 @@
-from typing import Any, Dict, Optional, Tuple
+import warnings
+from typing import Any, Dict, Optional, Tuple, Union
 
 import torch
 from torch import Tensor
 
 from kornia.augmentation._2d.geometric.base import GeometricAugmentationBase2D
+from kornia.constants import Resample
 from kornia.geometry.transform import elastic_transform2d
 
 
@@ -19,7 +21,9 @@
         alpha: The scaling factor that controls the intensity of the deformation
           in the y and x directions, respectively.
         align_corners: Interpolation flag used by `grid_sample`.
-        mode: Interpolation mode used by `grid_sample`. Either 'bilinear' or 'nearest'.
+        resample: Interpolation mode used by `grid_sample`. Either 'nearest' (0) or 'bilinear' (1).
+        mode: Deprecated: Interpolation mode used by `grid_sample`. Either 'bilinear' or 'nearest'.
+          Please use the `resample` argument instead.
         padding_mode: The padding used by ```grid_sample```. Either 'zeros', 'border' or 'refection'.
         same_on_batch: apply the same transformation across the batch.
         p: probability of applying the transformation.
@@ -49,7 +53,8 @@
         sigma: Tuple[float, float] = (32.0, 32.0),
         alpha: Tuple[float, float] = (1.0, 1.0),
         align_corners: bool = False,
-        mode: str = "bilinear",
+        resample: Union[str, int, Resample] = Resample.BILINEAR.name,
+        mode: Optional[str] = None,
         padding_mode: str = "zeros",
         same_on_batch: bool = False,
         p: float = 0.5,
@@ -59,12 +64,21 @@
         super().__init__(
             p=p, return_transform=return_transform, same_on_batch=same_on_batch, p_batch=1.0, keepdim=keepdim
         )
+        if mode is not None:
+            resample = mode
+            if not torch.jit.is_scripting():
+                warnings.warn(
+                    "`mode` argument has been deprecated. Please use the `resample` argument instead",
+                    DeprecationWarning,
+                    stacklevel=2,
+                )
+
         self.flags = dict(
             kernel_size=kernel_size,
             sigma=sigma,
             alpha=alpha,
             align_corners=align_corners,
-            mode=mode,
+            resample=Resample.get(resample),
             padding_mode=padding_mode,
         )
 
@@ -90,6 +104,6 @@
             flags["sigma"],
             flags["alpha"],
             flags["align_corners"],
-            flags["mode"],
+            flags["resample"].name.lower(),
             flags["padding_mode"],
         )

{"golden_diff": "diff --git a/kornia/augmentation/_2d/geometric/elastic_transform.py b/kornia/augmentation/_2d/geometric/elastic_transform.py\n--- a/kornia/augmentation/_2d/geometric/elastic_transform.py\n+++ b/kornia/augmentation/_2d/geometric/elastic_transform.py\n@@ -1,9 +1,11 @@\n-from typing import Any, Dict, Optional, Tuple\n+import warnings\n+from typing import Any, Dict, Optional, Tuple, Union\n \n import torch\n from torch import Tensor\n \n from kornia.augmentation._2d.geometric.base import GeometricAugmentationBase2D\n+from kornia.constants import Resample\n from kornia.geometry.transform import elastic_transform2d\n \n \n@@ -19,7 +21,9 @@\n         alpha: The scaling factor that controls the intensity of the deformation\n           in the y and x directions, respectively.\n         align_corners: Interpolation flag used by `grid_sample`.\n-        mode: Interpolation mode used by `grid_sample`. Either 'bilinear' or 'nearest'.\n+        resample: Interpolation mode used by `grid_sample`. Either 'nearest' (0) or 'bilinear' (1).\n+        mode: Deprecated: Interpolation mode used by `grid_sample`. Either 'bilinear' or 'nearest'.\n+          Please use the `resample` argument instead.\n         padding_mode: The padding used by ```grid_sample```. Either 'zeros', 'border' or 'refection'.\n         same_on_batch: apply the same transformation across the batch.\n         p: probability of applying the transformation.\n@@ -49,7 +53,8 @@\n         sigma: Tuple[float, float] = (32.0, 32.0),\n         alpha: Tuple[float, float] = (1.0, 1.0),\n         align_corners: bool = False,\n-        mode: str = \"bilinear\",\n+        resample: Union[str, int, Resample] = Resample.BILINEAR.name,\n+        mode: Optional[str] = None,\n         padding_mode: str = \"zeros\",\n         same_on_batch: bool = False,\n         p: float = 0.5,\n@@ -59,12 +64,21 @@\n         super().__init__(\n             p=p, return_transform=return_transform, same_on_batch=same_on_batch, p_batch=1.0, keepdim=keepdim\n         )\n+        if mode is not None:\n+            resample = mode\n+            if not torch.jit.is_scripting():\n+                warnings.warn(\n+                    \"`mode` argument has been deprecated. Please use the `resample` argument instead\",\n+                    DeprecationWarning,\n+                    stacklevel=2,\n+                )\n+\n         self.flags = dict(\n             kernel_size=kernel_size,\n             sigma=sigma,\n             alpha=alpha,\n             align_corners=align_corners,\n-            mode=mode,\n+            resample=Resample.get(resample),\n             padding_mode=padding_mode,\n         )\n \n@@ -90,6 +104,6 @@\n             flags[\"sigma\"],\n             flags[\"alpha\"],\n             flags[\"align_corners\"],\n-            flags[\"mode\"],\n+            flags[\"resample\"].name.lower(),\n             flags[\"padding_mode\"],\n         )\n", "issue": "No automatic `nearest` interpolation for masks in `RandomElasticTransform`\n### Describe the bug\r\n\r\nUsually, the data type `DataKey.MASK` uses the `nearest` interpolation method to preserve label index values (e.g. when using `RandomAffine`). However, this does not work for the `RandomElasticTransform` augmentation since the corresponding parameter is named `mode` and not `resample`. Hence the default argument to `AugmentationSequential`\r\n```python\r\nextra_args={DataKey.MASK: dict(resample=Resample.NEAREST, align_corners=True)}\r\n```\r\ndoes not trigger the `nearest` interpolation mode.\r\n\r\n### Reproduction steps\r\n\r\nHere is an example reproducing the issue of the current default interpolation for mask input types:\r\n```python\r\nimport torch\r\nimport kornia.augmentation as K\r\nfeatures = torch.rand(1, 1, 4, 4)\r\nlabels = torch.ones(1, 1, 4, 4, dtype=torch.float32) * 10\r\nlabels[:, :, :, :2] = 0\r\nlabels[:, :, :2, :] = 0\r\n# tensor([[[[ 0.,  0.,  0.,  0.],\r\n#           [ 0.,  0.,  0.,  0.],\r\n#           [ 0.,  0., 10., 10.],\r\n#           [ 0.,  0., 10., 10.]]]])\r\n\r\ncompose = K.AugmentationSequential(K.RandomElasticTransform(alpha=(10, 10)))\r\ntorch.manual_seed(0)\r\ncompose(features, labels, data_keys=[\"input\", \"mask\"])[1]\r\n# tensor([[[[0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00],\r\n#           [0.0000e+00, 0.0000e+00, 4.4417e-03, 4.3297e-03],\r\n#           [0.0000e+00, 0.0000e+00, 9.8832e+00, 1.0000e+01],\r\n#           [0.0000e+00, 0.0000e+00, 9.8833e+00, 1.0000e+01]]]])\r\n```\r\n\r\n\r\n### Expected behavior\r\n\r\nThe default behavior for the elastic transformation should be similar to the other transformations, i.e. `nearest` interpolation for mask types.\r\n\r\n### Environment\r\n- PyTorch Version (e.g., 1.0): 1.13\r\n- OS (e.g., Linux): Linux\r\n- How you installed PyTorch (`conda`, `pip`, source): pip\r\n- Build command you used (if compiling from source):\r\n- Python version: 3.10.4\r\n- CUDA/cuDNN version: 11.7\r\n- GPU models and configuration: 3090\r\n- Any other relevant information:\r\n\r\n\r\n### Additional context\r\n\r\nCurrent workaround for this issue is to manually set the interpolation mode:\r\n```python\r\ncompose = K.AugmentationSequential(*transforms, extra_args={DataKey.MASK: dict(resample=Resample.NEAREST, align_corners=True, mode=\"nearest\")})\r\n```\r\n\r\nOne option would be to rename the `mode` parameter to `resample`, than the default mask handling triggers as well. This would be a breaking change but I see that elastic transformation might get some exciting new functionality in the future anyway (issue #994) so this could be a combined change.\n", "before_files": [{"content": "from typing import Any, Dict, Optional, Tuple\n\nimport torch\nfrom torch import Tensor\n\nfrom kornia.augmentation._2d.geometric.base import GeometricAugmentationBase2D\nfrom kornia.geometry.transform import elastic_transform2d\n\n\nclass RandomElasticTransform(GeometricAugmentationBase2D):\n    r\"\"\"Add random elastic transformation to a tensor image.\n\n    .. image:: _static/img/RandomElasticTransform.png\n\n    Args:\n        kernel_size: the size of the Gaussian kernel.\n        sigma: The standard deviation of the Gaussian in the y and x directions,\n          respectively. Larger sigma results in smaller pixel displacements.\n        alpha: The scaling factor that controls the intensity of the deformation\n          in the y and x directions, respectively.\n        align_corners: Interpolation flag used by `grid_sample`.\n        mode: Interpolation mode used by `grid_sample`. Either 'bilinear' or 'nearest'.\n        padding_mode: The padding used by ```grid_sample```. Either 'zeros', 'border' or 'refection'.\n        same_on_batch: apply the same transformation across the batch.\n        p: probability of applying the transformation.\n        keepdim: whether to keep the output shape the same as input (True) or broadcast it\n            to the batch form (False).\n\n    .. note::\n        This function internally uses :func:`kornia.geometry.transform.elastic_transform2d`.\n\n    Examples:\n        >>> import torch\n        >>> img = torch.ones(1, 1, 2, 2)\n        >>> out = RandomElasticTransform()(img)\n        >>> out.shape\n        torch.Size([1, 1, 2, 2])\n\n    To apply the exact augmenation again, you may take the advantage of the previous parameter state:\n        >>> input = torch.randn(1, 3, 32, 32)\n        >>> aug = RandomElasticTransform(p=1.)\n        >>> (aug(input) == aug(input, params=aug._params)).all()\n        tensor(True)\n    \"\"\"\n\n    def __init__(\n        self,\n        kernel_size: Tuple[int, int] = (63, 63),\n        sigma: Tuple[float, float] = (32.0, 32.0),\n        alpha: Tuple[float, float] = (1.0, 1.0),\n        align_corners: bool = False,\n        mode: str = \"bilinear\",\n        padding_mode: str = \"zeros\",\n        same_on_batch: bool = False,\n        p: float = 0.5,\n        keepdim: bool = False,\n        return_transform: Optional[bool] = None,\n    ) -> None:\n        super().__init__(\n            p=p, return_transform=return_transform, same_on_batch=same_on_batch, p_batch=1.0, keepdim=keepdim\n        )\n        self.flags = dict(\n            kernel_size=kernel_size,\n            sigma=sigma,\n            alpha=alpha,\n            align_corners=align_corners,\n            mode=mode,\n            padding_mode=padding_mode,\n        )\n\n    def generate_parameters(self, shape: torch.Size) -> Dict[str, Tensor]:\n        B, _, H, W = shape\n        if self.same_on_batch:\n            noise = torch.rand(1, 2, H, W, device=self.device, dtype=self.dtype).repeat(B, 1, 1, 1)\n        else:\n            noise = torch.rand(B, 2, H, W, device=self.device, dtype=self.dtype)\n        return dict(noise=noise * 2 - 1)\n\n    # TODO: It is incorrect to return identity\n    def compute_transformation(self, input: Tensor, params: Dict[str, Tensor], flags: Dict[str, Any]) -> Tensor:\n        return self.identity_matrix(input)\n\n    def apply_transform(\n        self, input: Tensor, params: Dict[str, Tensor], flags: Dict[str, Any], transform: Optional[Tensor] = None\n    ) -> Tensor:\n        return elastic_transform2d(\n            input,\n            params[\"noise\"].to(input),\n            flags[\"kernel_size\"],\n            flags[\"sigma\"],\n            flags[\"alpha\"],\n            flags[\"align_corners\"],\n            flags[\"mode\"],\n            flags[\"padding_mode\"],\n        )\n", "path": "kornia/augmentation/_2d/geometric/elastic_transform.py"}], "after_files": [{"content": "import warnings\nfrom typing import Any, Dict, Optional, Tuple, Union\n\nimport torch\nfrom torch import Tensor\n\nfrom kornia.augmentation._2d.geometric.base import GeometricAugmentationBase2D\nfrom kornia.constants import Resample\nfrom kornia.geometry.transform import elastic_transform2d\n\n\nclass RandomElasticTransform(GeometricAugmentationBase2D):\n    r\"\"\"Add random elastic transformation to a tensor image.\n\n    .. image:: _static/img/RandomElasticTransform.png\n\n    Args:\n        kernel_size: the size of the Gaussian kernel.\n        sigma: The standard deviation of the Gaussian in the y and x directions,\n          respectively. Larger sigma results in smaller pixel displacements.\n        alpha: The scaling factor that controls the intensity of the deformation\n          in the y and x directions, respectively.\n        align_corners: Interpolation flag used by `grid_sample`.\n        resample: Interpolation mode used by `grid_sample`. Either 'nearest' (0) or 'bilinear' (1).\n        mode: Deprecated: Interpolation mode used by `grid_sample`. Either 'bilinear' or 'nearest'.\n          Please use the `resample` argument instead.\n        padding_mode: The padding used by ```grid_sample```. Either 'zeros', 'border' or 'refection'.\n        same_on_batch: apply the same transformation across the batch.\n        p: probability of applying the transformation.\n        keepdim: whether to keep the output shape the same as input (True) or broadcast it\n            to the batch form (False).\n\n    .. note::\n        This function internally uses :func:`kornia.geometry.transform.elastic_transform2d`.\n\n    Examples:\n        >>> import torch\n        >>> img = torch.ones(1, 1, 2, 2)\n        >>> out = RandomElasticTransform()(img)\n        >>> out.shape\n        torch.Size([1, 1, 2, 2])\n\n    To apply the exact augmenation again, you may take the advantage of the previous parameter state:\n        >>> input = torch.randn(1, 3, 32, 32)\n        >>> aug = RandomElasticTransform(p=1.)\n        >>> (aug(input) == aug(input, params=aug._params)).all()\n        tensor(True)\n    \"\"\"\n\n    def __init__(\n        self,\n        kernel_size: Tuple[int, int] = (63, 63),\n        sigma: Tuple[float, float] = (32.0, 32.0),\n        alpha: Tuple[float, float] = (1.0, 1.0),\n        align_corners: bool = False,\n        resample: Union[str, int, Resample] = Resample.BILINEAR.name,\n        mode: Optional[str] = None,\n        padding_mode: str = \"zeros\",\n        same_on_batch: bool = False,\n        p: float = 0.5,\n        keepdim: bool = False,\n        return_transform: Optional[bool] = None,\n    ) -> None:\n        super().__init__(\n            p=p, return_transform=return_transform, same_on_batch=same_on_batch, p_batch=1.0, keepdim=keepdim\n        )\n        if mode is not None:\n            resample = mode\n            if not torch.jit.is_scripting():\n                warnings.warn(\n                    \"`mode` argument has been deprecated. Please use the `resample` argument instead\",\n                    DeprecationWarning,\n                    stacklevel=2,\n                )\n\n        self.flags = dict(\n            kernel_size=kernel_size,\n            sigma=sigma,\n            alpha=alpha,\n            align_corners=align_corners,\n            resample=Resample.get(resample),\n            padding_mode=padding_mode,\n        )\n\n    def generate_parameters(self, shape: torch.Size) -> Dict[str, Tensor]:\n        B, _, H, W = shape\n        if self.same_on_batch:\n            noise = torch.rand(1, 2, H, W, device=self.device, dtype=self.dtype).repeat(B, 1, 1, 1)\n        else:\n            noise = torch.rand(B, 2, H, W, device=self.device, dtype=self.dtype)\n        return dict(noise=noise * 2 - 1)\n\n    # TODO: It is incorrect to return identity\n    def compute_transformation(self, input: Tensor, params: Dict[str, Tensor], flags: Dict[str, Any]) -> Tensor:\n        return self.identity_matrix(input)\n\n    def apply_transform(\n        self, input: Tensor, params: Dict[str, Tensor], flags: Dict[str, Any], transform: Optional[Tensor] = None\n    ) -> Tensor:\n        return elastic_transform2d(\n            input,\n            params[\"noise\"].to(input),\n            flags[\"kernel_size\"],\n            flags[\"sigma\"],\n            flags[\"alpha\"],\n            flags[\"align_corners\"],\n            flags[\"resample\"].name.lower(),\n            flags[\"padding_mode\"],\n        )\n", "path": "kornia/augmentation/_2d/geometric/elastic_transform.py"}]}