We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
_adapted_uniform is broken for tensors > 1 dimension and same_on_batch=True
## 🐛 Bug

`kornia.augmentation.utils.helpers._adapted_uniform` is broken for `len(shape) > 1` and `same_on_batch=True`

## To Reproduce

```python
from kornia.augmentation.utils.helpers import _adapted_uniform

shape = (1, 2)
_adapted_uniform(shape, 0.0, 1.0, same_on_batch=True)
```

```
RuntimeError: Number of dimensions of repeat dims can not be smaller than number of dimensions of tensor
```


--- 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/utils/helpers.py`
Content:
```
1 from typing import Tuple, Union, List, cast, Optional
2 
3 import torch
4 from torch.distributions import Uniform, Beta
5 
6 
7 def _infer_batch_shape(input: Union[torch.Tensor, Tuple[torch.Tensor, torch.Tensor]]) -> torch.Size:
8     r"""Infer input shape. Input may be either (tensor,) or (tensor, transform_matrix)
9     """
10     if isinstance(input, tuple):
11         tensor = _transform_input(input[0])
12     else:
13         tensor = _transform_input(input)
14     return tensor.shape
15 
16 
17 def _infer_batch_shape3d(input: Union[torch.Tensor, Tuple[torch.Tensor, torch.Tensor]]) -> torch.Size:
18     r"""Infer input shape. Input may be either (tensor,) or (tensor, transform_matrix)
19     """
20     if isinstance(input, tuple):
21         tensor = _transform_input3d(input[0])
22     else:
23         tensor = _transform_input3d(input)
24     return tensor.shape
25 
26 
27 def _transform_input(input: torch.Tensor) -> torch.Tensor:
28     r"""Reshape an input tensor to be (*, C, H, W). Accept either (H, W), (C, H, W) or (*, C, H, W).
29     Args:
30         input: torch.Tensor
31 
32     Returns:
33         torch.Tensor
34     """
35     if not torch.is_tensor(input):
36         raise TypeError(f"Input type is not a torch.Tensor. Got {type(input)}")
37 
38     if len(input.shape) not in [2, 3, 4]:
39         raise ValueError(
40             f"Input size must have a shape of either (H, W), (C, H, W) or (*, C, H, W). Got {input.shape}")
41 
42     if len(input.shape) == 2:
43         input = input.unsqueeze(0)
44 
45     if len(input.shape) == 3:
46         input = input.unsqueeze(0)
47 
48     return input
49 
50 
51 def _transform_input3d(input: torch.Tensor) -> torch.Tensor:
52     r"""Reshape an input tensor to be (*, C, D, H, W). Accept either (D, H, W), (C, D, H, W) or (*, C, D, H, W).
53     Args:
54         input: torch.Tensor
55 
56     Returns:
57         torch.Tensor
58     """
59     if not torch.is_tensor(input):
60         raise TypeError(f"Input type is not a torch.Tensor. Got {type(input)}")
61 
62     if len(input.shape) not in [3, 4, 5]:
63         raise ValueError(
64             f"Input size must have a shape of either (D, H, W), (C, D, H, W) or (*, C, D, H, W). Got {input.shape}")
65 
66     if len(input.shape) == 3:
67         input = input.unsqueeze(0)
68 
69     if len(input.shape) == 4:
70         input = input.unsqueeze(0)
71 
72     return input
73 
74 
75 def _validate_input_dtype(input: torch.Tensor, accepted_dtypes: List) -> None:
76     r"""Check if the dtype of the input tensor is in the range of accepted_dtypes
77     Args:
78         input: torch.Tensor
79         accepted_dtypes: List. e.g. [torch.float32, torch.float64]
80     """
81     if input.dtype not in accepted_dtypes:
82         raise TypeError(f"Expected input of {accepted_dtypes}. Got {input.dtype}")
83 
84 
85 def _validate_shape(shape: Union[Tuple, torch.Size], required_shapes: List[str] = ["BCHW"]) -> None:
86     r"""Check if the dtype of the input tensor is in the range of accepted_dtypes
87     Args:
88         input: torch.Tensor
89         required_shapes: List. e.g. ["BCHW", "BCDHW"]
90     """
91     passed = False
92     for required_shape in required_shapes:
93         if len(shape) == len(required_shape):
94             passed = True
95             break
96     if not passed:
97         raise TypeError(f"Expected input shape in {required_shape}. Got {shape}.")
98 
99 
100 def _validate_input_shape(input: torch.Tensor, channel_index: int, number: int) -> bool:
101     r"""Validate if an input has the right shape. e.g. to check if an input is channel first.
102     If channel first, the second channel of an RGB input shall be fixed to 3. To verify using:
103         _validate_input_shape(input, 1, 3)
104     Args:
105         input: torch.Tensor
106         channel_index: int
107         number: int
108     Returns:
109         bool
110     """
111     return input.shape[channel_index] == number
112 
113 
114 def _adapted_uniform(
115     shape: Union[Tuple, torch.Size],
116     low: Union[float, int, torch.Tensor],
117     high: Union[float, int, torch.Tensor],
118     same_on_batch=False
119 ) -> torch.Tensor:
120     r""" The uniform sampling function that accepts 'same_on_batch'.
121     If same_on_batch is True, all values generated will be exactly same given a batch_size (shape[0]).
122     By default, same_on_batch is set to False.
123     """
124     if not isinstance(low, torch.Tensor):
125         low = torch.tensor(low, dtype=torch.float32)
126     if not isinstance(high, torch.Tensor):
127         high = torch.tensor(high, dtype=torch.float32)
128     dist = Uniform(low, high)
129     if same_on_batch:
130         return dist.rsample((1, *shape[1:])).repeat(shape[0])
131     else:
132         return dist.rsample(shape)
133 
134 
135 def _adapted_beta(
136     shape: Union[Tuple, torch.Size],
137     a: Union[float, int, torch.Tensor],
138     b: Union[float, int, torch.Tensor],
139     same_on_batch=False
140 ) -> torch.Tensor:
141     r""" The beta sampling function that accepts 'same_on_batch'.
142     If same_on_batch is True, all values generated will be exactly same given a batch_size (shape[0]).
143     By default, same_on_batch is set to False.
144     """
145     if not isinstance(a, torch.Tensor):
146         a = torch.tensor(a, dtype=torch.float32)
147     if not isinstance(b, torch.Tensor):
148         b = torch.tensor(b, dtype=torch.float32)
149     dist = Beta(a, b)
150     if same_on_batch:
151         return dist.rsample((1, *shape[1:])).repeat(shape[0])
152     else:
153         return dist.rsample(shape)
154 
155 
156 def _check_and_bound(factor: Union[torch.Tensor, float, Tuple[float, float], List[float]], name: str,
157                      center: float = 0., bounds: Tuple[float, float] = (0, float('inf'))) -> torch.Tensor:
158     r"""Check inputs and compute the corresponding factor bounds
159     """
160     factor_bound: torch.Tensor
161     if not isinstance(factor, torch.Tensor):
162         factor = torch.tensor(factor, dtype=torch.float32)
163 
164     if factor.dim() == 0:
165         _center = torch.tensor(center, dtype=torch.float32)
166 
167         if factor < 0:
168             raise ValueError(f"If {name} is a single number number, it must be non negative. Got {factor.item()}")
169 
170         factor_bound = torch.tensor([_center - factor, _center + factor], dtype=torch.float32)
171         # Should be something other than clamp
172         # Currently, single value factor will not out of scope as long as the user provided it.
173         factor_bound = torch.clamp(factor_bound, bounds[0], bounds[1])
174 
175     elif factor.shape[0] == 2 and factor.dim() == 1:
176 
177         if not bounds[0] <= factor[0] or not bounds[1] >= factor[1]:
178             raise ValueError(f"{name} out of bounds. Expected inside {bounds}, got {factor}.")
179 
180         if not bounds[0] <= factor[0] <= factor[1] <= bounds[1]:
181             raise ValueError(f"{name}[0] should be smaller than {name}[1] got {factor}")
182 
183         factor_bound = factor
184 
185     else:
186 
187         raise TypeError(
188             f"The {name} should be a float number or a tuple with length 2 whose values move between {bounds}.")
189 
190     return factor_bound
191 
192 
193 def _shape_validation(param: torch.Tensor, shape: Union[tuple, list], name: str) -> None:
194     assert param.shape == torch.Size(shape), f"Invalid shape for {name}. Expected {shape}. Got {param.shape}"
195
```
--- 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/utils/helpers.py b/kornia/augmentation/utils/helpers.py
--- a/kornia/augmentation/utils/helpers.py
+++ b/kornia/augmentation/utils/helpers.py
@@ -127,7 +127,7 @@
         high = torch.tensor(high, dtype=torch.float32)
     dist = Uniform(low, high)
     if same_on_batch:
-        return dist.rsample((1, *shape[1:])).repeat(shape[0])
+        return dist.rsample((1, *shape[1:])).repeat(shape[0], *[1] * (len(shape) - 1))
     else:
         return dist.rsample(shape)

{"golden_diff": "diff --git a/kornia/augmentation/utils/helpers.py b/kornia/augmentation/utils/helpers.py\n--- a/kornia/augmentation/utils/helpers.py\n+++ b/kornia/augmentation/utils/helpers.py\n@@ -127,7 +127,7 @@\n         high = torch.tensor(high, dtype=torch.float32)\n     dist = Uniform(low, high)\n     if same_on_batch:\n-        return dist.rsample((1, *shape[1:])).repeat(shape[0])\n+        return dist.rsample((1, *shape[1:])).repeat(shape[0], *[1] * (len(shape) - 1))\n     else:\n         return dist.rsample(shape)\n", "issue": "_adapted_uniform is broken for tensors > 1 dimension and same_on_batch=True\n## \ud83d\udc1b Bug\r\n\r\n`kornia.augmentation.utils.helpers._adapted_uniform` is broken for `len(shape) > 1` and `same_on_batch=True`\r\n\r\n## To Reproduce\r\n\r\n```python\r\nfrom kornia.augmentation.utils.helpers import _adapted_uniform\r\n\r\nshape = (1, 2)\r\n_adapted_uniform(shape, 0.0, 1.0, same_on_batch=True)\r\n```\r\n\r\n```\r\nRuntimeError: Number of dimensions of repeat dims can not be smaller than number of dimensions of tensor\r\n```\r\n\n", "before_files": [{"content": "from typing import Tuple, Union, List, cast, Optional\n\nimport torch\nfrom torch.distributions import Uniform, Beta\n\n\ndef _infer_batch_shape(input: Union[torch.Tensor, Tuple[torch.Tensor, torch.Tensor]]) -> torch.Size:\n    r\"\"\"Infer input shape. Input may be either (tensor,) or (tensor, transform_matrix)\n    \"\"\"\n    if isinstance(input, tuple):\n        tensor = _transform_input(input[0])\n    else:\n        tensor = _transform_input(input)\n    return tensor.shape\n\n\ndef _infer_batch_shape3d(input: Union[torch.Tensor, Tuple[torch.Tensor, torch.Tensor]]) -> torch.Size:\n    r\"\"\"Infer input shape. Input may be either (tensor,) or (tensor, transform_matrix)\n    \"\"\"\n    if isinstance(input, tuple):\n        tensor = _transform_input3d(input[0])\n    else:\n        tensor = _transform_input3d(input)\n    return tensor.shape\n\n\ndef _transform_input(input: torch.Tensor) -> torch.Tensor:\n    r\"\"\"Reshape an input tensor to be (*, C, H, W). Accept either (H, W), (C, H, W) or (*, C, H, W).\n    Args:\n        input: torch.Tensor\n\n    Returns:\n        torch.Tensor\n    \"\"\"\n    if not torch.is_tensor(input):\n        raise TypeError(f\"Input type is not a torch.Tensor. Got {type(input)}\")\n\n    if len(input.shape) not in [2, 3, 4]:\n        raise ValueError(\n            f\"Input size must have a shape of either (H, W), (C, H, W) or (*, C, H, W). Got {input.shape}\")\n\n    if len(input.shape) == 2:\n        input = input.unsqueeze(0)\n\n    if len(input.shape) == 3:\n        input = input.unsqueeze(0)\n\n    return input\n\n\ndef _transform_input3d(input: torch.Tensor) -> torch.Tensor:\n    r\"\"\"Reshape an input tensor to be (*, C, D, H, W). Accept either (D, H, W), (C, D, H, W) or (*, C, D, H, W).\n    Args:\n        input: torch.Tensor\n\n    Returns:\n        torch.Tensor\n    \"\"\"\n    if not torch.is_tensor(input):\n        raise TypeError(f\"Input type is not a torch.Tensor. Got {type(input)}\")\n\n    if len(input.shape) not in [3, 4, 5]:\n        raise ValueError(\n            f\"Input size must have a shape of either (D, H, W), (C, D, H, W) or (*, C, D, H, W). Got {input.shape}\")\n\n    if len(input.shape) == 3:\n        input = input.unsqueeze(0)\n\n    if len(input.shape) == 4:\n        input = input.unsqueeze(0)\n\n    return input\n\n\ndef _validate_input_dtype(input: torch.Tensor, accepted_dtypes: List) -> None:\n    r\"\"\"Check if the dtype of the input tensor is in the range of accepted_dtypes\n    Args:\n        input: torch.Tensor\n        accepted_dtypes: List. e.g. [torch.float32, torch.float64]\n    \"\"\"\n    if input.dtype not in accepted_dtypes:\n        raise TypeError(f\"Expected input of {accepted_dtypes}. Got {input.dtype}\")\n\n\ndef _validate_shape(shape: Union[Tuple, torch.Size], required_shapes: List[str] = [\"BCHW\"]) -> None:\n    r\"\"\"Check if the dtype of the input tensor is in the range of accepted_dtypes\n    Args:\n        input: torch.Tensor\n        required_shapes: List. e.g. [\"BCHW\", \"BCDHW\"]\n    \"\"\"\n    passed = False\n    for required_shape in required_shapes:\n        if len(shape) == len(required_shape):\n            passed = True\n            break\n    if not passed:\n        raise TypeError(f\"Expected input shape in {required_shape}. Got {shape}.\")\n\n\ndef _validate_input_shape(input: torch.Tensor, channel_index: int, number: int) -> bool:\n    r\"\"\"Validate if an input has the right shape. e.g. to check if an input is channel first.\n    If channel first, the second channel of an RGB input shall be fixed to 3. To verify using:\n        _validate_input_shape(input, 1, 3)\n    Args:\n        input: torch.Tensor\n        channel_index: int\n        number: int\n    Returns:\n        bool\n    \"\"\"\n    return input.shape[channel_index] == number\n\n\ndef _adapted_uniform(\n    shape: Union[Tuple, torch.Size],\n    low: Union[float, int, torch.Tensor],\n    high: Union[float, int, torch.Tensor],\n    same_on_batch=False\n) -> torch.Tensor:\n    r\"\"\" The uniform sampling function that accepts 'same_on_batch'.\n    If same_on_batch is True, all values generated will be exactly same given a batch_size (shape[0]).\n    By default, same_on_batch is set to False.\n    \"\"\"\n    if not isinstance(low, torch.Tensor):\n        low = torch.tensor(low, dtype=torch.float32)\n    if not isinstance(high, torch.Tensor):\n        high = torch.tensor(high, dtype=torch.float32)\n    dist = Uniform(low, high)\n    if same_on_batch:\n        return dist.rsample((1, *shape[1:])).repeat(shape[0])\n    else:\n        return dist.rsample(shape)\n\n\ndef _adapted_beta(\n    shape: Union[Tuple, torch.Size],\n    a: Union[float, int, torch.Tensor],\n    b: Union[float, int, torch.Tensor],\n    same_on_batch=False\n) -> torch.Tensor:\n    r\"\"\" The beta sampling function that accepts 'same_on_batch'.\n    If same_on_batch is True, all values generated will be exactly same given a batch_size (shape[0]).\n    By default, same_on_batch is set to False.\n    \"\"\"\n    if not isinstance(a, torch.Tensor):\n        a = torch.tensor(a, dtype=torch.float32)\n    if not isinstance(b, torch.Tensor):\n        b = torch.tensor(b, dtype=torch.float32)\n    dist = Beta(a, b)\n    if same_on_batch:\n        return dist.rsample((1, *shape[1:])).repeat(shape[0])\n    else:\n        return dist.rsample(shape)\n\n\ndef _check_and_bound(factor: Union[torch.Tensor, float, Tuple[float, float], List[float]], name: str,\n                     center: float = 0., bounds: Tuple[float, float] = (0, float('inf'))) -> torch.Tensor:\n    r\"\"\"Check inputs and compute the corresponding factor bounds\n    \"\"\"\n    factor_bound: torch.Tensor\n    if not isinstance(factor, torch.Tensor):\n        factor = torch.tensor(factor, dtype=torch.float32)\n\n    if factor.dim() == 0:\n        _center = torch.tensor(center, dtype=torch.float32)\n\n        if factor < 0:\n            raise ValueError(f\"If {name} is a single number number, it must be non negative. Got {factor.item()}\")\n\n        factor_bound = torch.tensor([_center - factor, _center + factor], dtype=torch.float32)\n        # Should be something other than clamp\n        # Currently, single value factor will not out of scope as long as the user provided it.\n        factor_bound = torch.clamp(factor_bound, bounds[0], bounds[1])\n\n    elif factor.shape[0] == 2 and factor.dim() == 1:\n\n        if not bounds[0] <= factor[0] or not bounds[1] >= factor[1]:\n            raise ValueError(f\"{name} out of bounds. Expected inside {bounds}, got {factor}.\")\n\n        if not bounds[0] <= factor[0] <= factor[1] <= bounds[1]:\n            raise ValueError(f\"{name}[0] should be smaller than {name}[1] got {factor}\")\n\n        factor_bound = factor\n\n    else:\n\n        raise TypeError(\n            f\"The {name} should be a float number or a tuple with length 2 whose values move between {bounds}.\")\n\n    return factor_bound\n\n\ndef _shape_validation(param: torch.Tensor, shape: Union[tuple, list], name: str) -> None:\n    assert param.shape == torch.Size(shape), f\"Invalid shape for {name}. Expected {shape}. Got {param.shape}\"\n", "path": "kornia/augmentation/utils/helpers.py"}], "after_files": [{"content": "from typing import Tuple, Union, List, cast, Optional\n\nimport torch\nfrom torch.distributions import Uniform, Beta\n\n\ndef _infer_batch_shape(input: Union[torch.Tensor, Tuple[torch.Tensor, torch.Tensor]]) -> torch.Size:\n    r\"\"\"Infer input shape. Input may be either (tensor,) or (tensor, transform_matrix)\n    \"\"\"\n    if isinstance(input, tuple):\n        tensor = _transform_input(input[0])\n    else:\n        tensor = _transform_input(input)\n    return tensor.shape\n\n\ndef _infer_batch_shape3d(input: Union[torch.Tensor, Tuple[torch.Tensor, torch.Tensor]]) -> torch.Size:\n    r\"\"\"Infer input shape. Input may be either (tensor,) or (tensor, transform_matrix)\n    \"\"\"\n    if isinstance(input, tuple):\n        tensor = _transform_input3d(input[0])\n    else:\n        tensor = _transform_input3d(input)\n    return tensor.shape\n\n\ndef _transform_input(input: torch.Tensor) -> torch.Tensor:\n    r\"\"\"Reshape an input tensor to be (*, C, H, W). Accept either (H, W), (C, H, W) or (*, C, H, W).\n    Args:\n        input: torch.Tensor\n\n    Returns:\n        torch.Tensor\n    \"\"\"\n    if not torch.is_tensor(input):\n        raise TypeError(f\"Input type is not a torch.Tensor. Got {type(input)}\")\n\n    if len(input.shape) not in [2, 3, 4]:\n        raise ValueError(\n            f\"Input size must have a shape of either (H, W), (C, H, W) or (*, C, H, W). Got {input.shape}\")\n\n    if len(input.shape) == 2:\n        input = input.unsqueeze(0)\n\n    if len(input.shape) == 3:\n        input = input.unsqueeze(0)\n\n    return input\n\n\ndef _transform_input3d(input: torch.Tensor) -> torch.Tensor:\n    r\"\"\"Reshape an input tensor to be (*, C, D, H, W). Accept either (D, H, W), (C, D, H, W) or (*, C, D, H, W).\n    Args:\n        input: torch.Tensor\n\n    Returns:\n        torch.Tensor\n    \"\"\"\n    if not torch.is_tensor(input):\n        raise TypeError(f\"Input type is not a torch.Tensor. Got {type(input)}\")\n\n    if len(input.shape) not in [3, 4, 5]:\n        raise ValueError(\n            f\"Input size must have a shape of either (D, H, W), (C, D, H, W) or (*, C, D, H, W). Got {input.shape}\")\n\n    if len(input.shape) == 3:\n        input = input.unsqueeze(0)\n\n    if len(input.shape) == 4:\n        input = input.unsqueeze(0)\n\n    return input\n\n\ndef _validate_input_dtype(input: torch.Tensor, accepted_dtypes: List) -> None:\n    r\"\"\"Check if the dtype of the input tensor is in the range of accepted_dtypes\n    Args:\n        input: torch.Tensor\n        accepted_dtypes: List. e.g. [torch.float32, torch.float64]\n    \"\"\"\n    if input.dtype not in accepted_dtypes:\n        raise TypeError(f\"Expected input of {accepted_dtypes}. Got {input.dtype}\")\n\n\ndef _validate_shape(shape: Union[Tuple, torch.Size], required_shapes: List[str] = [\"BCHW\"]) -> None:\n    r\"\"\"Check if the dtype of the input tensor is in the range of accepted_dtypes\n    Args:\n        input: torch.Tensor\n        required_shapes: List. e.g. [\"BCHW\", \"BCDHW\"]\n    \"\"\"\n    passed = False\n    for required_shape in required_shapes:\n        if len(shape) == len(required_shape):\n            passed = True\n            break\n    if not passed:\n        raise TypeError(f\"Expected input shape in {required_shape}. Got {shape}.\")\n\n\ndef _validate_input_shape(input: torch.Tensor, channel_index: int, number: int) -> bool:\n    r\"\"\"Validate if an input has the right shape. e.g. to check if an input is channel first.\n    If channel first, the second channel of an RGB input shall be fixed to 3. To verify using:\n        _validate_input_shape(input, 1, 3)\n    Args:\n        input: torch.Tensor\n        channel_index: int\n        number: int\n    Returns:\n        bool\n    \"\"\"\n    return input.shape[channel_index] == number\n\n\ndef _adapted_uniform(\n    shape: Union[Tuple, torch.Size],\n    low: Union[float, int, torch.Tensor],\n    high: Union[float, int, torch.Tensor],\n    same_on_batch=False\n) -> torch.Tensor:\n    r\"\"\" The uniform sampling function that accepts 'same_on_batch'.\n    If same_on_batch is True, all values generated will be exactly same given a batch_size (shape[0]).\n    By default, same_on_batch is set to False.\n    \"\"\"\n    if not isinstance(low, torch.Tensor):\n        low = torch.tensor(low, dtype=torch.float32)\n    if not isinstance(high, torch.Tensor):\n        high = torch.tensor(high, dtype=torch.float32)\n    dist = Uniform(low, high)\n    if same_on_batch:\n        return dist.rsample((1, *shape[1:])).repeat(shape[0], *[1] * (len(shape) - 1))\n    else:\n        return dist.rsample(shape)\n\n\ndef _adapted_beta(\n    shape: Union[Tuple, torch.Size],\n    a: Union[float, int, torch.Tensor],\n    b: Union[float, int, torch.Tensor],\n    same_on_batch=False\n) -> torch.Tensor:\n    r\"\"\" The beta sampling function that accepts 'same_on_batch'.\n    If same_on_batch is True, all values generated will be exactly same given a batch_size (shape[0]).\n    By default, same_on_batch is set to False.\n    \"\"\"\n    if not isinstance(a, torch.Tensor):\n        a = torch.tensor(a, dtype=torch.float32)\n    if not isinstance(b, torch.Tensor):\n        b = torch.tensor(b, dtype=torch.float32)\n    dist = Beta(a, b)\n    if same_on_batch:\n        return dist.rsample((1, *shape[1:])).repeat(shape[0])\n    else:\n        return dist.rsample(shape)\n\n\ndef _check_and_bound(factor: Union[torch.Tensor, float, Tuple[float, float], List[float]], name: str,\n                     center: float = 0., bounds: Tuple[float, float] = (0, float('inf'))) -> torch.Tensor:\n    r\"\"\"Check inputs and compute the corresponding factor bounds\n    \"\"\"\n    factor_bound: torch.Tensor\n    if not isinstance(factor, torch.Tensor):\n        factor = torch.tensor(factor, dtype=torch.float32)\n\n    if factor.dim() == 0:\n        _center = torch.tensor(center, dtype=torch.float32)\n\n        if factor < 0:\n            raise ValueError(f\"If {name} is a single number number, it must be non negative. Got {factor.item()}\")\n\n        factor_bound = torch.tensor([_center - factor, _center + factor], dtype=torch.float32)\n        # Should be something other than clamp\n        # Currently, single value factor will not out of scope as long as the user provided it.\n        factor_bound = torch.clamp(factor_bound, bounds[0], bounds[1])\n\n    elif factor.shape[0] == 2 and factor.dim() == 1:\n\n        if not bounds[0] <= factor[0] or not bounds[1] >= factor[1]:\n            raise ValueError(f\"{name} out of bounds. Expected inside {bounds}, got {factor}.\")\n\n        if not bounds[0] <= factor[0] <= factor[1] <= bounds[1]:\n            raise ValueError(f\"{name}[0] should be smaller than {name}[1] got {factor}\")\n\n        factor_bound = factor\n\n    else:\n\n        raise TypeError(\n            f\"The {name} should be a float number or a tuple with length 2 whose values move between {bounds}.\")\n\n    return factor_bound\n\n\ndef _shape_validation(param: torch.Tensor, shape: Union[tuple, list], name: str) -> None:\n    assert param.shape == torch.Size(shape), f\"Invalid shape for {name}. Expected {shape}. Got {param.shape}\"\n", "path": "kornia/augmentation/utils/helpers.py"}]}