We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Weird behavior of LongestMaxSize
### Describe the bug

Hello me again,

I might be doing something wrong with the way I use kornia augmentations, please let me know if it is the case.

I was expecting `LongestMaxSize` in kornia to perform similarily as the albumentation implementation. Meaning that I can throw any images with different shapes to the the transformation function and get an image with different shapes but similar ratios. The largest size being equal to the value given to `LongestMaxSize`.

See bellow a small code sample that disturbs me.

### Reproduction steps

```bash
import kornia.augmentation as K
a = torch.ones((512, 256))
b = torch.ones((512, 756))

print("first try")
transfo = K.LongestMaxSize(max_size=256, p=1.)

print(transfo(a).shape)
print(transfo(b).shape)

print("second try")

a = torch.ones((512, 256))
b = torch.ones((512, 756))

transfo = K.LongestMaxSize(max_size=256, p=1.)
print(transfo(b).shape)
print(transfo(a).shape)

Outputs:
first try
torch.Size([1, 1, 256, 128])
torch.Size([1, 1, 256, 128])
second try
torch.Size([1, 1, 173, 256])
torch.Size([1, 1, 173, 256])
```


### Expected behavior

I would expect to have the same values for the transformations no matter the order of the elements.

ie `transfo(a).shape == torch.Size([1, 1, 256, 128])` and `transfo(b).shape ==torch.Size([1, 1, 173, 256])`

Am I missing something here ?

### Environment

```shell
kornia='0.6.9'
torch='1.12.1+cu113'
```


### 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/random_generator/_2d/resize.py`
Content:
```
1 from typing import Dict, Tuple, Union
2 
3 import torch
4 
5 from kornia.augmentation.random_generator.base import RandomGeneratorBase
6 from kornia.augmentation.utils import _common_param_check
7 from kornia.core import Device, Tensor, tensor
8 from kornia.geometry.bbox import bbox_generator
9 from kornia.geometry.transform.affwarp import _side_to_image_size
10 
11 
12 class ResizeGenerator(RandomGeneratorBase):
13     r"""Get parameters for ```resize``` transformation for resize transform.
14 
15     Args:
16         resize_to: Desired output size of the crop, like (h, w).
17         side: Which side to resize if `resize_to` is only of type int.
18 
19     Returns:
20         parameters to be passed for transformation.
21             - src (Tensor): cropping bounding boxes with a shape of (B, 4, 2).
22             - dst (Tensor): output bounding boxes with a shape (B, 4, 2).
23             - input_size (Tensor): (h, w) from batch input.
24             - resize_to (tuple): new (h, w) for batch input.
25 
26     Note:
27         The generated random numbers are not reproducible across different devices and dtypes. By default,
28         the parameters will be generated on CPU in float32. This can be changed by calling
29         ``self.set_rng_device_and_dtype(device="cuda", dtype=torch.float64)``.
30     """
31 
32     def __init__(self, resize_to: Union[int, Tuple[int, int]], side: str = "short") -> None:
33         super().__init__()
34         self.output_size = resize_to
35         self.side = side
36 
37     def __repr__(self) -> str:
38         repr = f"output_size={self.output_size}"
39         return repr
40 
41     def make_samplers(self, device: Device, dtype: torch.dtype) -> None:
42         self.device = device
43         self.dtype = dtype
44         pass
45 
46     def forward(self, batch_shape: torch.Size, same_on_batch: bool = False) -> Dict[str, Tensor]:
47         batch_size = batch_shape[0]
48         _common_param_check(batch_size, same_on_batch)
49         _device = self.device
50         _dtype = self.dtype
51 
52         if batch_size == 0:
53             return dict(
54                 src=torch.zeros([0, 4, 2], device=_device, dtype=_dtype),
55                 dst=torch.zeros([0, 4, 2], device=_device, dtype=_dtype),
56             )
57 
58         input_size = h, w = (batch_shape[-2], batch_shape[-1])
59 
60         src = bbox_generator(
61             tensor(0, device=_device, dtype=_dtype),
62             tensor(0, device=_device, dtype=_dtype),
63             tensor(input_size[1], device=_device, dtype=_dtype),
64             tensor(input_size[0], device=_device, dtype=_dtype),
65         ).repeat(batch_size, 1, 1)
66 
67         if isinstance(self.output_size, int):
68             aspect_ratio = w / h
69             self.output_size = _side_to_image_size(self.output_size, aspect_ratio, self.side)
70 
71         if not (
72             len(self.output_size) == 2
73             and isinstance(self.output_size[0], (int,))
74             and isinstance(self.output_size[1], (int,))
75             and self.output_size[0] > 0
76             and self.output_size[1] > 0
77         ):
78             raise AssertionError(f"`resize_to` must be a tuple of 2 positive integers. Got {self.output_size}.")
79 
80         dst = bbox_generator(
81             tensor(0, device=_device, dtype=_dtype),
82             tensor(0, device=_device, dtype=_dtype),
83             tensor(self.output_size[1], device=_device, dtype=_dtype),
84             tensor(self.output_size[0], device=_device, dtype=_dtype),
85         ).repeat(batch_size, 1, 1)
86 
87         _input_size = tensor(input_size, device=_device, dtype=torch.long).expand(batch_size, -1)
88         _output_size = tensor(self.output_size, device=_device, dtype=torch.long).expand(batch_size, -1)
89 
90         return dict(src=src, dst=dst, input_size=_input_size, output_size=_output_size)
91
```
--- 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/random_generator/_2d/resize.py b/kornia/augmentation/random_generator/_2d/resize.py
--- a/kornia/augmentation/random_generator/_2d/resize.py
+++ b/kornia/augmentation/random_generator/_2d/resize.py
@@ -66,25 +66,27 @@
 
         if isinstance(self.output_size, int):
             aspect_ratio = w / h
-            self.output_size = _side_to_image_size(self.output_size, aspect_ratio, self.side)
+            output_size = _side_to_image_size(self.output_size, aspect_ratio, self.side)
+        else:
+            output_size = self.output_size
 
         if not (
-            len(self.output_size) == 2
-            and isinstance(self.output_size[0], (int,))
-            and isinstance(self.output_size[1], (int,))
-            and self.output_size[0] > 0
-            and self.output_size[1] > 0
+            len(output_size) == 2
+            and isinstance(output_size[0], (int,))
+            and isinstance(output_size[1], (int,))
+            and output_size[0] > 0
+            and output_size[1] > 0
         ):
-            raise AssertionError(f"`resize_to` must be a tuple of 2 positive integers. Got {self.output_size}.")
+            raise AssertionError(f"`resize_to` must be a tuple of 2 positive integers. Got {output_size}.")
 
         dst = bbox_generator(
             tensor(0, device=_device, dtype=_dtype),
             tensor(0, device=_device, dtype=_dtype),
-            tensor(self.output_size[1], device=_device, dtype=_dtype),
-            tensor(self.output_size[0], device=_device, dtype=_dtype),
+            tensor(output_size[1], device=_device, dtype=_dtype),
+            tensor(output_size[0], device=_device, dtype=_dtype),
         ).repeat(batch_size, 1, 1)
 
         _input_size = tensor(input_size, device=_device, dtype=torch.long).expand(batch_size, -1)
-        _output_size = tensor(self.output_size, device=_device, dtype=torch.long).expand(batch_size, -1)
+        _output_size = tensor(output_size, device=_device, dtype=torch.long).expand(batch_size, -1)
 
         return dict(src=src, dst=dst, input_size=_input_size, output_size=_output_size)

{"golden_diff": "diff --git a/kornia/augmentation/random_generator/_2d/resize.py b/kornia/augmentation/random_generator/_2d/resize.py\n--- a/kornia/augmentation/random_generator/_2d/resize.py\n+++ b/kornia/augmentation/random_generator/_2d/resize.py\n@@ -66,25 +66,27 @@\n \n         if isinstance(self.output_size, int):\n             aspect_ratio = w / h\n-            self.output_size = _side_to_image_size(self.output_size, aspect_ratio, self.side)\n+            output_size = _side_to_image_size(self.output_size, aspect_ratio, self.side)\n+        else:\n+            output_size = self.output_size\n \n         if not (\n-            len(self.output_size) == 2\n-            and isinstance(self.output_size[0], (int,))\n-            and isinstance(self.output_size[1], (int,))\n-            and self.output_size[0] > 0\n-            and self.output_size[1] > 0\n+            len(output_size) == 2\n+            and isinstance(output_size[0], (int,))\n+            and isinstance(output_size[1], (int,))\n+            and output_size[0] > 0\n+            and output_size[1] > 0\n         ):\n-            raise AssertionError(f\"`resize_to` must be a tuple of 2 positive integers. Got {self.output_size}.\")\n+            raise AssertionError(f\"`resize_to` must be a tuple of 2 positive integers. Got {output_size}.\")\n \n         dst = bbox_generator(\n             tensor(0, device=_device, dtype=_dtype),\n             tensor(0, device=_device, dtype=_dtype),\n-            tensor(self.output_size[1], device=_device, dtype=_dtype),\n-            tensor(self.output_size[0], device=_device, dtype=_dtype),\n+            tensor(output_size[1], device=_device, dtype=_dtype),\n+            tensor(output_size[0], device=_device, dtype=_dtype),\n         ).repeat(batch_size, 1, 1)\n \n         _input_size = tensor(input_size, device=_device, dtype=torch.long).expand(batch_size, -1)\n-        _output_size = tensor(self.output_size, device=_device, dtype=torch.long).expand(batch_size, -1)\n+        _output_size = tensor(output_size, device=_device, dtype=torch.long).expand(batch_size, -1)\n \n         return dict(src=src, dst=dst, input_size=_input_size, output_size=_output_size)\n", "issue": "Weird behavior of LongestMaxSize\n### Describe the bug\r\n\r\nHello me again,\r\n\r\nI might be doing something wrong with the way I use kornia augmentations, please let me know if it is the case.\r\n\r\nI was expecting `LongestMaxSize` in kornia to perform similarily as the albumentation implementation. Meaning that I can throw any images with different shapes to the the transformation function and get an image with different shapes but similar ratios. The largest size being equal to the value given to `LongestMaxSize`.\r\n\r\nSee bellow a small code sample that disturbs me.\r\n\r\n### Reproduction steps\r\n\r\n```bash\r\nimport kornia.augmentation as K\r\na = torch.ones((512, 256))\r\nb = torch.ones((512, 756))\r\n\r\nprint(\"first try\")\r\ntransfo = K.LongestMaxSize(max_size=256, p=1.)\r\n\r\nprint(transfo(a).shape)\r\nprint(transfo(b).shape)\r\n\r\nprint(\"second try\")\r\n\r\na = torch.ones((512, 256))\r\nb = torch.ones((512, 756))\r\n\r\ntransfo = K.LongestMaxSize(max_size=256, p=1.)\r\nprint(transfo(b).shape)\r\nprint(transfo(a).shape)\r\n\r\nOutputs:\r\nfirst try\r\ntorch.Size([1, 1, 256, 128])\r\ntorch.Size([1, 1, 256, 128])\r\nsecond try\r\ntorch.Size([1, 1, 173, 256])\r\ntorch.Size([1, 1, 173, 256])\r\n```\r\n\r\n\r\n### Expected behavior\r\n\r\nI would expect to have the same values for the transformations no matter the order of the elements.\r\n\r\nie `transfo(a).shape == torch.Size([1, 1, 256, 128])` and `transfo(b).shape ==torch.Size([1, 1, 173, 256])`\r\n\r\nAm I missing something here ?\r\n\r\n### Environment\r\n\r\n```shell\r\nkornia='0.6.9'\r\ntorch='1.12.1+cu113'\r\n```\r\n\r\n\r\n### Additional context\r\n\r\n_No response_\n", "before_files": [{"content": "from typing import Dict, Tuple, Union\n\nimport torch\n\nfrom kornia.augmentation.random_generator.base import RandomGeneratorBase\nfrom kornia.augmentation.utils import _common_param_check\nfrom kornia.core import Device, Tensor, tensor\nfrom kornia.geometry.bbox import bbox_generator\nfrom kornia.geometry.transform.affwarp import _side_to_image_size\n\n\nclass ResizeGenerator(RandomGeneratorBase):\n    r\"\"\"Get parameters for ```resize``` transformation for resize transform.\n\n    Args:\n        resize_to: Desired output size of the crop, like (h, w).\n        side: Which side to resize if `resize_to` is only of type int.\n\n    Returns:\n        parameters to be passed for transformation.\n            - src (Tensor): cropping bounding boxes with a shape of (B, 4, 2).\n            - dst (Tensor): output bounding boxes with a shape (B, 4, 2).\n            - input_size (Tensor): (h, w) from batch input.\n            - resize_to (tuple): new (h, w) for batch input.\n\n    Note:\n        The generated random numbers are not reproducible across different devices and dtypes. By default,\n        the parameters will be generated on CPU in float32. This can be changed by calling\n        ``self.set_rng_device_and_dtype(device=\"cuda\", dtype=torch.float64)``.\n    \"\"\"\n\n    def __init__(self, resize_to: Union[int, Tuple[int, int]], side: str = \"short\") -> None:\n        super().__init__()\n        self.output_size = resize_to\n        self.side = side\n\n    def __repr__(self) -> str:\n        repr = f\"output_size={self.output_size}\"\n        return repr\n\n    def make_samplers(self, device: Device, dtype: torch.dtype) -> None:\n        self.device = device\n        self.dtype = dtype\n        pass\n\n    def forward(self, batch_shape: torch.Size, same_on_batch: bool = False) -> Dict[str, Tensor]:\n        batch_size = batch_shape[0]\n        _common_param_check(batch_size, same_on_batch)\n        _device = self.device\n        _dtype = self.dtype\n\n        if batch_size == 0:\n            return dict(\n                src=torch.zeros([0, 4, 2], device=_device, dtype=_dtype),\n                dst=torch.zeros([0, 4, 2], device=_device, dtype=_dtype),\n            )\n\n        input_size = h, w = (batch_shape[-2], batch_shape[-1])\n\n        src = bbox_generator(\n            tensor(0, device=_device, dtype=_dtype),\n            tensor(0, device=_device, dtype=_dtype),\n            tensor(input_size[1], device=_device, dtype=_dtype),\n            tensor(input_size[0], device=_device, dtype=_dtype),\n        ).repeat(batch_size, 1, 1)\n\n        if isinstance(self.output_size, int):\n            aspect_ratio = w / h\n            self.output_size = _side_to_image_size(self.output_size, aspect_ratio, self.side)\n\n        if not (\n            len(self.output_size) == 2\n            and isinstance(self.output_size[0], (int,))\n            and isinstance(self.output_size[1], (int,))\n            and self.output_size[0] > 0\n            and self.output_size[1] > 0\n        ):\n            raise AssertionError(f\"`resize_to` must be a tuple of 2 positive integers. Got {self.output_size}.\")\n\n        dst = bbox_generator(\n            tensor(0, device=_device, dtype=_dtype),\n            tensor(0, device=_device, dtype=_dtype),\n            tensor(self.output_size[1], device=_device, dtype=_dtype),\n            tensor(self.output_size[0], device=_device, dtype=_dtype),\n        ).repeat(batch_size, 1, 1)\n\n        _input_size = tensor(input_size, device=_device, dtype=torch.long).expand(batch_size, -1)\n        _output_size = tensor(self.output_size, device=_device, dtype=torch.long).expand(batch_size, -1)\n\n        return dict(src=src, dst=dst, input_size=_input_size, output_size=_output_size)\n", "path": "kornia/augmentation/random_generator/_2d/resize.py"}], "after_files": [{"content": "from typing import Dict, Tuple, Union\n\nimport torch\n\nfrom kornia.augmentation.random_generator.base import RandomGeneratorBase\nfrom kornia.augmentation.utils import _common_param_check\nfrom kornia.core import Device, Tensor, tensor\nfrom kornia.geometry.bbox import bbox_generator\nfrom kornia.geometry.transform.affwarp import _side_to_image_size\n\n\nclass ResizeGenerator(RandomGeneratorBase):\n    r\"\"\"Get parameters for ```resize``` transformation for resize transform.\n\n    Args:\n        resize_to: Desired output size of the crop, like (h, w).\n        side: Which side to resize if `resize_to` is only of type int.\n\n    Returns:\n        parameters to be passed for transformation.\n            - src (Tensor): cropping bounding boxes with a shape of (B, 4, 2).\n            - dst (Tensor): output bounding boxes with a shape (B, 4, 2).\n            - input_size (Tensor): (h, w) from batch input.\n            - resize_to (tuple): new (h, w) for batch input.\n\n    Note:\n        The generated random numbers are not reproducible across different devices and dtypes. By default,\n        the parameters will be generated on CPU in float32. This can be changed by calling\n        ``self.set_rng_device_and_dtype(device=\"cuda\", dtype=torch.float64)``.\n    \"\"\"\n\n    def __init__(self, resize_to: Union[int, Tuple[int, int]], side: str = \"short\") -> None:\n        super().__init__()\n        self.output_size = resize_to\n        self.side = side\n\n    def __repr__(self) -> str:\n        repr = f\"output_size={self.output_size}\"\n        return repr\n\n    def make_samplers(self, device: Device, dtype: torch.dtype) -> None:\n        self.device = device\n        self.dtype = dtype\n        pass\n\n    def forward(self, batch_shape: torch.Size, same_on_batch: bool = False) -> Dict[str, Tensor]:\n        batch_size = batch_shape[0]\n        _common_param_check(batch_size, same_on_batch)\n        _device = self.device\n        _dtype = self.dtype\n\n        if batch_size == 0:\n            return dict(\n                src=torch.zeros([0, 4, 2], device=_device, dtype=_dtype),\n                dst=torch.zeros([0, 4, 2], device=_device, dtype=_dtype),\n            )\n\n        input_size = h, w = (batch_shape[-2], batch_shape[-1])\n\n        src = bbox_generator(\n            tensor(0, device=_device, dtype=_dtype),\n            tensor(0, device=_device, dtype=_dtype),\n            tensor(input_size[1], device=_device, dtype=_dtype),\n            tensor(input_size[0], device=_device, dtype=_dtype),\n        ).repeat(batch_size, 1, 1)\n\n        if isinstance(self.output_size, int):\n            aspect_ratio = w / h\n            output_size = _side_to_image_size(self.output_size, aspect_ratio, self.side)\n        else:\n            output_size = self.output_size\n\n        if not (\n            len(output_size) == 2\n            and isinstance(output_size[0], (int,))\n            and isinstance(output_size[1], (int,))\n            and output_size[0] > 0\n            and output_size[1] > 0\n        ):\n            raise AssertionError(f\"`resize_to` must be a tuple of 2 positive integers. Got {output_size}.\")\n\n        dst = bbox_generator(\n            tensor(0, device=_device, dtype=_dtype),\n            tensor(0, device=_device, dtype=_dtype),\n            tensor(output_size[1], device=_device, dtype=_dtype),\n            tensor(output_size[0], device=_device, dtype=_dtype),\n        ).repeat(batch_size, 1, 1)\n\n        _input_size = tensor(input_size, device=_device, dtype=torch.long).expand(batch_size, -1)\n        _output_size = tensor(output_size, device=_device, dtype=torch.long).expand(batch_size, -1)\n\n        return dict(src=src, dst=dst, input_size=_input_size, output_size=_output_size)\n", "path": "kornia/augmentation/random_generator/_2d/resize.py"}]}