We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
`RandomMotionBlur` fails when `kernel_size` is a `Tuple[int, int]`
### Describe the bug

Using the `RandomMotionBlur` augmentation with a tuple for `kernel_size` throws a `TypeError`. This appears to happen because internally `apply_transform` is trying to convert `kernel_size` to an `int` while receiving a collection of numbers

### Reproduction steps

```python
import kornia as K
import torch

x = torch.rand(3,3,224,224)
tfm = K.augmentation.RandomMotionBlur((7,21), (15.,15.), (-1.,1.), p=1)

tfm(x)
```


### Expected behavior

Successfully perform the transform with a different kernel size every batch

### Environment

```shell
wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py
```
- PyTorch Version (e.g., 1.0): 1.10.1
- OS (e.g., Linux): macOS 12.0.1 (x86_64)
- How you installed PyTorch (`conda`, `pip`, source): pip
- Python version: 3.7.10
- CUDA/cuDNN version: NA
- GPU models and configuration: NA
- Any other relevant information: NA




### Additional context

Full stack trace:

```python
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-4-a535d4587048> in <module>
----> 1 tfm(x)

~/miniconda3/lib/python3.7/site-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)
   1100         if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
   1101                 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1102             return forward_call(*input, **kwargs)
   1103         # Do not call functions when jit is used
   1104         full_backward_hooks, non_full_backward_hooks = [], []

~/miniconda3/lib/python3.7/site-packages/kornia/augmentation/base.py in forward(self, input, params, return_transform)
    268 
    269         self._params = params
--> 270         output = self.apply_func(in_tensor, in_transform, self._params, return_transform)
    271         return _transform_output_shape(output, ori_shape) if self.keepdim else output
    272 

~/miniconda3/lib/python3.7/site-packages/kornia/augmentation/base.py in apply_func(self, in_tensor, in_transform, params, return_transform)
    227         elif torch.sum(to_apply) == len(to_apply):
    228             trans_matrix = self.compute_transformation(in_tensor, params)
--> 229             output = self.apply_transform(in_tensor, params, trans_matrix)
    230         else:
    231             output = in_tensor.clone()

~/miniconda3/lib/python3.7/site-packages/kornia/augmentation/augmentation.py in apply_transform(self, input, params, transform)
   1400         self, input: torch.Tensor, params: Dict[str, torch.Tensor], transform: Optional[torch.Tensor] = None
   1401     ) -> torch.Tensor:
-> 1402         kernel_size: int = cast(int, params["ksize_factor"].unique().item())
   1403         angle = params["angle_factor"]
   1404         direction = params["direction_factor"]

ValueError: only one element tensors can be converted to Python scalars
```

--- 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/intensity/motion_blur.py`
Content:
```
1 from typing import Dict, Optional, Tuple, Union, cast
2 
3 import torch
4 
5 from kornia.augmentation import random_generator as rg
6 from kornia.augmentation._2d.intensity.base import IntensityAugmentationBase2D
7 from kornia.constants import BorderType, Resample
8 from kornia.filters import motion_blur
9 
10 
11 class RandomMotionBlur(IntensityAugmentationBase2D):
12     r"""Perform motion blur on 2D images (4D tensor).
13 
14     .. image:: _static/img/RandomMotionBlur.png
15 
16     Args:
17         p: probability of applying the transformation.
18         kernel_size: motion kernel size (odd and positive).
19             If int, the kernel will have a fixed size.
20             If Tuple[int, int], it will randomly generate the value from the range batch-wisely.
21         angle: angle of the motion blur in degrees (anti-clockwise rotation).
22             If float, it will generate the value from (-angle, angle).
23         direction: forward/backward direction of the motion blur.
24             Lower values towards -1.0 will point the motion blur towards the back (with angle provided via angle),
25             while higher values towards 1.0 will point the motion blur forward. A value of 0.0 leads to a
26             uniformly (but still angled) motion blur.
27             If float, it will generate the value from (-direction, direction).
28             If Tuple[int, int], it will randomly generate the value from the range.
29         border_type: the padding mode to be applied before convolving.
30             CONSTANT = 0, REFLECT = 1, REPLICATE = 2, CIRCULAR = 3.
31         resample: the interpolation mode.
32         keepdim: whether to keep the output shape the same as input (True) or broadcast it
33                  to the batch form (False).
34 
35     Shape:
36         - Input: :math:`(C, H, W)` or :math:`(B, C, H, W)`, Optional: :math:`(B, 3, 3)`
37         - Output: :math:`(B, C, H, W)`
38 
39     Note:
40         Input tensor must be float and normalized into [0, 1] for the best differentiability support.
41         Additionally, this function accepts another transformation tensor (:math:`(B, 3, 3)`), then the
42         applied transformation will be merged int to the input transformation tensor and returned.
43 
44         Please set ``resample`` to ``'bilinear'`` if more meaningful gradients wanted.
45 
46     .. note::
47         This function internally uses :func:`kornia.filters.motion_blur`.
48 
49     Examples:
50         >>> rng = torch.manual_seed(0)
51         >>> input = torch.ones(1, 1, 5, 5)
52         >>> motion_blur = RandomMotionBlur(3, 35., 0.5, p=1.)
53         >>> motion_blur(input)
54         tensor([[[[0.5773, 1.0000, 1.0000, 1.0000, 0.7561],
55                   [0.5773, 1.0000, 1.0000, 1.0000, 0.7561],
56                   [0.5773, 1.0000, 1.0000, 1.0000, 0.7561],
57                   [0.5773, 1.0000, 1.0000, 1.0000, 0.7561],
58                   [0.5773, 1.0000, 1.0000, 1.0000, 0.7561]]]])
59 
60     To apply the exact augmenation again, you may take the advantage of the previous parameter state:
61         >>> input = torch.randn(1, 3, 32, 32)
62         >>> aug = RandomMotionBlur(3, 35., 0.5, p=1.)
63         >>> (aug(input) == aug(input, params=aug._params)).all()
64         tensor(True)
65     """
66 
67     def __init__(
68         self,
69         kernel_size: Union[int, Tuple[int, int]],
70         angle: Union[torch.Tensor, float, Tuple[float, float]],
71         direction: Union[torch.Tensor, float, Tuple[float, float]],
72         border_type: Union[int, str, BorderType] = BorderType.CONSTANT.name,
73         resample: Union[str, int, Resample] = Resample.NEAREST.name,
74         return_transform: bool = False,
75         same_on_batch: bool = False,
76         p: float = 0.5,
77         keepdim: bool = False,
78     ) -> None:
79         super().__init__(p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim)
80         self._param_generator = rg.MotionBlurGenerator(kernel_size, angle, direction)
81         self.flags = dict(border_type=BorderType.get(border_type), resample=Resample.get(resample))
82 
83     def apply_transform(
84         self, input: torch.Tensor, params: Dict[str, torch.Tensor], transform: Optional[torch.Tensor] = None
85     ) -> torch.Tensor:
86         kernel_size: int = cast(int, params["ksize_factor"].unique().item())
87         angle = params["angle_factor"]
88         direction = params["direction_factor"]
89         return motion_blur(
90             input,
91             kernel_size,
92             angle,
93             direction,
94             border_type=self.flags["border_type"].name.lower(),
95             mode=self.flags["resample"].name.lower(),
96         )
97
```
--- 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/intensity/motion_blur.py b/kornia/augmentation/_2d/intensity/motion_blur.py
--- a/kornia/augmentation/_2d/intensity/motion_blur.py
+++ b/kornia/augmentation/_2d/intensity/motion_blur.py
@@ -1,4 +1,4 @@
-from typing import Dict, Optional, Tuple, Union, cast
+from typing import Dict, List, Optional, Tuple, Union, cast
 
 import torch
 
@@ -83,14 +83,14 @@
     def apply_transform(
         self, input: torch.Tensor, params: Dict[str, torch.Tensor], transform: Optional[torch.Tensor] = None
     ) -> torch.Tensor:
-        kernel_size: int = cast(int, params["ksize_factor"].unique().item())
-        angle = params["angle_factor"]
-        direction = params["direction_factor"]
+        # sample a kernel size
+        kernel_size_list: List[int] = params["ksize_factor"].tolist()
+        idx: int = cast(int, torch.randint(len(kernel_size_list), (1,)).item())
         return motion_blur(
             input,
-            kernel_size,
-            angle,
-            direction,
+            kernel_size=kernel_size_list[idx],
+            angle=params["angle_factor"],
+            direction=params["direction_factor"],
             border_type=self.flags["border_type"].name.lower(),
             mode=self.flags["resample"].name.lower(),
         )

{"golden_diff": "diff --git a/kornia/augmentation/_2d/intensity/motion_blur.py b/kornia/augmentation/_2d/intensity/motion_blur.py\n--- a/kornia/augmentation/_2d/intensity/motion_blur.py\n+++ b/kornia/augmentation/_2d/intensity/motion_blur.py\n@@ -1,4 +1,4 @@\n-from typing import Dict, Optional, Tuple, Union, cast\n+from typing import Dict, List, Optional, Tuple, Union, cast\n \n import torch\n \n@@ -83,14 +83,14 @@\n     def apply_transform(\n         self, input: torch.Tensor, params: Dict[str, torch.Tensor], transform: Optional[torch.Tensor] = None\n     ) -> torch.Tensor:\n-        kernel_size: int = cast(int, params[\"ksize_factor\"].unique().item())\n-        angle = params[\"angle_factor\"]\n-        direction = params[\"direction_factor\"]\n+        # sample a kernel size\n+        kernel_size_list: List[int] = params[\"ksize_factor\"].tolist()\n+        idx: int = cast(int, torch.randint(len(kernel_size_list), (1,)).item())\n         return motion_blur(\n             input,\n-            kernel_size,\n-            angle,\n-            direction,\n+            kernel_size=kernel_size_list[idx],\n+            angle=params[\"angle_factor\"],\n+            direction=params[\"direction_factor\"],\n             border_type=self.flags[\"border_type\"].name.lower(),\n             mode=self.flags[\"resample\"].name.lower(),\n         )\n", "issue": "`RandomMotionBlur` fails when `kernel_size` is a `Tuple[int, int]`\n### Describe the bug\r\n\r\nUsing the `RandomMotionBlur` augmentation with a tuple for `kernel_size` throws a `TypeError`. This appears to happen because internally `apply_transform` is trying to convert `kernel_size` to an `int` while receiving a collection of numbers\r\n\r\n### Reproduction steps\r\n\r\n```python\r\nimport kornia as K\r\nimport torch\r\n\r\nx = torch.rand(3,3,224,224)\r\ntfm = K.augmentation.RandomMotionBlur((7,21), (15.,15.), (-1.,1.), p=1)\r\n\r\ntfm(x)\r\n```\r\n\r\n\r\n### Expected behavior\r\n\r\nSuccessfully perform the transform with a different kernel size every batch\r\n\r\n### Environment\r\n\r\n```shell\r\nwget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py\r\n# For security purposes, please check the contents of collect_env.py before running it.\r\npython collect_env.py\r\n```\r\n- PyTorch Version (e.g., 1.0): 1.10.1\r\n- OS (e.g., Linux): macOS 12.0.1 (x86_64)\r\n- How you installed PyTorch (`conda`, `pip`, source): pip\r\n- Python version: 3.7.10\r\n- CUDA/cuDNN version: NA\r\n- GPU models and configuration: NA\r\n- Any other relevant information: NA\r\n\r\n\r\n\r\n\r\n### Additional context\r\n\r\nFull stack trace:\r\n\r\n```python\r\n---------------------------------------------------------------------------\r\nValueError                                Traceback (most recent call last)\r\n<ipython-input-4-a535d4587048> in <module>\r\n----> 1 tfm(x)\r\n\r\n~/miniconda3/lib/python3.7/site-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)\r\n   1100         if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks\r\n   1101                 or _global_forward_hooks or _global_forward_pre_hooks):\r\n-> 1102             return forward_call(*input, **kwargs)\r\n   1103         # Do not call functions when jit is used\r\n   1104         full_backward_hooks, non_full_backward_hooks = [], []\r\n\r\n~/miniconda3/lib/python3.7/site-packages/kornia/augmentation/base.py in forward(self, input, params, return_transform)\r\n    268 \r\n    269         self._params = params\r\n--> 270         output = self.apply_func(in_tensor, in_transform, self._params, return_transform)\r\n    271         return _transform_output_shape(output, ori_shape) if self.keepdim else output\r\n    272 \r\n\r\n~/miniconda3/lib/python3.7/site-packages/kornia/augmentation/base.py in apply_func(self, in_tensor, in_transform, params, return_transform)\r\n    227         elif torch.sum(to_apply) == len(to_apply):\r\n    228             trans_matrix = self.compute_transformation(in_tensor, params)\r\n--> 229             output = self.apply_transform(in_tensor, params, trans_matrix)\r\n    230         else:\r\n    231             output = in_tensor.clone()\r\n\r\n~/miniconda3/lib/python3.7/site-packages/kornia/augmentation/augmentation.py in apply_transform(self, input, params, transform)\r\n   1400         self, input: torch.Tensor, params: Dict[str, torch.Tensor], transform: Optional[torch.Tensor] = None\r\n   1401     ) -> torch.Tensor:\r\n-> 1402         kernel_size: int = cast(int, params[\"ksize_factor\"].unique().item())\r\n   1403         angle = params[\"angle_factor\"]\r\n   1404         direction = params[\"direction_factor\"]\r\n\r\nValueError: only one element tensors can be converted to Python scalars\r\n```\n", "before_files": [{"content": "from typing import Dict, Optional, Tuple, Union, cast\n\nimport torch\n\nfrom kornia.augmentation import random_generator as rg\nfrom kornia.augmentation._2d.intensity.base import IntensityAugmentationBase2D\nfrom kornia.constants import BorderType, Resample\nfrom kornia.filters import motion_blur\n\n\nclass RandomMotionBlur(IntensityAugmentationBase2D):\n    r\"\"\"Perform motion blur on 2D images (4D tensor).\n\n    .. image:: _static/img/RandomMotionBlur.png\n\n    Args:\n        p: probability of applying the transformation.\n        kernel_size: motion kernel size (odd and positive).\n            If int, the kernel will have a fixed size.\n            If Tuple[int, int], it will randomly generate the value from the range batch-wisely.\n        angle: angle of the motion blur in degrees (anti-clockwise rotation).\n            If float, it will generate the value from (-angle, angle).\n        direction: forward/backward direction of the motion blur.\n            Lower values towards -1.0 will point the motion blur towards the back (with angle provided via angle),\n            while higher values towards 1.0 will point the motion blur forward. A value of 0.0 leads to a\n            uniformly (but still angled) motion blur.\n            If float, it will generate the value from (-direction, direction).\n            If Tuple[int, int], it will randomly generate the value from the range.\n        border_type: the padding mode to be applied before convolving.\n            CONSTANT = 0, REFLECT = 1, REPLICATE = 2, CIRCULAR = 3.\n        resample: the interpolation mode.\n        keepdim: whether to keep the output shape the same as input (True) or broadcast it\n                 to the batch form (False).\n\n    Shape:\n        - Input: :math:`(C, H, W)` or :math:`(B, C, H, W)`, Optional: :math:`(B, 3, 3)`\n        - Output: :math:`(B, C, H, W)`\n\n    Note:\n        Input tensor must be float and normalized into [0, 1] for the best differentiability support.\n        Additionally, this function accepts another transformation tensor (:math:`(B, 3, 3)`), then the\n        applied transformation will be merged int to the input transformation tensor and returned.\n\n        Please set ``resample`` to ``'bilinear'`` if more meaningful gradients wanted.\n\n    .. note::\n        This function internally uses :func:`kornia.filters.motion_blur`.\n\n    Examples:\n        >>> rng = torch.manual_seed(0)\n        >>> input = torch.ones(1, 1, 5, 5)\n        >>> motion_blur = RandomMotionBlur(3, 35., 0.5, p=1.)\n        >>> motion_blur(input)\n        tensor([[[[0.5773, 1.0000, 1.0000, 1.0000, 0.7561],\n                  [0.5773, 1.0000, 1.0000, 1.0000, 0.7561],\n                  [0.5773, 1.0000, 1.0000, 1.0000, 0.7561],\n                  [0.5773, 1.0000, 1.0000, 1.0000, 0.7561],\n                  [0.5773, 1.0000, 1.0000, 1.0000, 0.7561]]]])\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 = RandomMotionBlur(3, 35., 0.5, p=1.)\n        >>> (aug(input) == aug(input, params=aug._params)).all()\n        tensor(True)\n    \"\"\"\n\n    def __init__(\n        self,\n        kernel_size: Union[int, Tuple[int, int]],\n        angle: Union[torch.Tensor, float, Tuple[float, float]],\n        direction: Union[torch.Tensor, float, Tuple[float, float]],\n        border_type: Union[int, str, BorderType] = BorderType.CONSTANT.name,\n        resample: Union[str, int, Resample] = Resample.NEAREST.name,\n        return_transform: bool = False,\n        same_on_batch: bool = False,\n        p: float = 0.5,\n        keepdim: bool = False,\n    ) -> None:\n        super().__init__(p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim)\n        self._param_generator = rg.MotionBlurGenerator(kernel_size, angle, direction)\n        self.flags = dict(border_type=BorderType.get(border_type), resample=Resample.get(resample))\n\n    def apply_transform(\n        self, input: torch.Tensor, params: Dict[str, torch.Tensor], transform: Optional[torch.Tensor] = None\n    ) -> torch.Tensor:\n        kernel_size: int = cast(int, params[\"ksize_factor\"].unique().item())\n        angle = params[\"angle_factor\"]\n        direction = params[\"direction_factor\"]\n        return motion_blur(\n            input,\n            kernel_size,\n            angle,\n            direction,\n            border_type=self.flags[\"border_type\"].name.lower(),\n            mode=self.flags[\"resample\"].name.lower(),\n        )\n", "path": "kornia/augmentation/_2d/intensity/motion_blur.py"}], "after_files": [{"content": "from typing import Dict, List, Optional, Tuple, Union, cast\n\nimport torch\n\nfrom kornia.augmentation import random_generator as rg\nfrom kornia.augmentation._2d.intensity.base import IntensityAugmentationBase2D\nfrom kornia.constants import BorderType, Resample\nfrom kornia.filters import motion_blur\n\n\nclass RandomMotionBlur(IntensityAugmentationBase2D):\n    r\"\"\"Perform motion blur on 2D images (4D tensor).\n\n    .. image:: _static/img/RandomMotionBlur.png\n\n    Args:\n        p: probability of applying the transformation.\n        kernel_size: motion kernel size (odd and positive).\n            If int, the kernel will have a fixed size.\n            If Tuple[int, int], it will randomly generate the value from the range batch-wisely.\n        angle: angle of the motion blur in degrees (anti-clockwise rotation).\n            If float, it will generate the value from (-angle, angle).\n        direction: forward/backward direction of the motion blur.\n            Lower values towards -1.0 will point the motion blur towards the back (with angle provided via angle),\n            while higher values towards 1.0 will point the motion blur forward. A value of 0.0 leads to a\n            uniformly (but still angled) motion blur.\n            If float, it will generate the value from (-direction, direction).\n            If Tuple[int, int], it will randomly generate the value from the range.\n        border_type: the padding mode to be applied before convolving.\n            CONSTANT = 0, REFLECT = 1, REPLICATE = 2, CIRCULAR = 3.\n        resample: the interpolation mode.\n        keepdim: whether to keep the output shape the same as input (True) or broadcast it\n                 to the batch form (False).\n\n    Shape:\n        - Input: :math:`(C, H, W)` or :math:`(B, C, H, W)`, Optional: :math:`(B, 3, 3)`\n        - Output: :math:`(B, C, H, W)`\n\n    Note:\n        Input tensor must be float and normalized into [0, 1] for the best differentiability support.\n        Additionally, this function accepts another transformation tensor (:math:`(B, 3, 3)`), then the\n        applied transformation will be merged int to the input transformation tensor and returned.\n\n        Please set ``resample`` to ``'bilinear'`` if more meaningful gradients wanted.\n\n    .. note::\n        This function internally uses :func:`kornia.filters.motion_blur`.\n\n    Examples:\n        >>> rng = torch.manual_seed(0)\n        >>> input = torch.ones(1, 1, 5, 5)\n        >>> motion_blur = RandomMotionBlur(3, 35., 0.5, p=1.)\n        >>> motion_blur(input)\n        tensor([[[[0.5773, 1.0000, 1.0000, 1.0000, 0.7561],\n                  [0.5773, 1.0000, 1.0000, 1.0000, 0.7561],\n                  [0.5773, 1.0000, 1.0000, 1.0000, 0.7561],\n                  [0.5773, 1.0000, 1.0000, 1.0000, 0.7561],\n                  [0.5773, 1.0000, 1.0000, 1.0000, 0.7561]]]])\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 = RandomMotionBlur(3, 35., 0.5, p=1.)\n        >>> (aug(input) == aug(input, params=aug._params)).all()\n        tensor(True)\n    \"\"\"\n\n    def __init__(\n        self,\n        kernel_size: Union[int, Tuple[int, int]],\n        angle: Union[torch.Tensor, float, Tuple[float, float]],\n        direction: Union[torch.Tensor, float, Tuple[float, float]],\n        border_type: Union[int, str, BorderType] = BorderType.CONSTANT.name,\n        resample: Union[str, int, Resample] = Resample.NEAREST.name,\n        return_transform: bool = False,\n        same_on_batch: bool = False,\n        p: float = 0.5,\n        keepdim: bool = False,\n    ) -> None:\n        super().__init__(p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim)\n        self._param_generator = rg.MotionBlurGenerator(kernel_size, angle, direction)\n        self.flags = dict(border_type=BorderType.get(border_type), resample=Resample.get(resample))\n\n    def apply_transform(\n        self, input: torch.Tensor, params: Dict[str, torch.Tensor], transform: Optional[torch.Tensor] = None\n    ) -> torch.Tensor:\n        # sample a kernel size\n        kernel_size_list: List[int] = params[\"ksize_factor\"].tolist()\n        idx: int = cast(int, torch.randint(len(kernel_size_list), (1,)).item())\n        return motion_blur(\n            input,\n            kernel_size=kernel_size_list[idx],\n            angle=params[\"angle_factor\"],\n            direction=params[\"direction_factor\"],\n            border_type=self.flags[\"border_type\"].name.lower(),\n            mode=self.flags[\"resample\"].name.lower(),\n        )\n", "path": "kornia/augmentation/_2d/intensity/motion_blur.py"}]}