We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
median
The PyTorch front end median function implemented in #13212 does not follow the correct behaviour. PyTorch's median returns a named tuple with the median and their indices when a axis is provided to reduce along. The incorrect implementation has been reverted in #13480 

https://pytorch.org/docs/stable/generated/torch.median.html

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `ivy/functional/frontends/torch/reduction_ops.py`
Content:
```
1 import ivy
2 from ivy.func_wrapper import with_unsupported_dtypes
3 from ivy.functional.frontends.torch.func_wrapper import to_ivy_arrays_and_back
4 from collections import namedtuple
5 
6 
7 @to_ivy_arrays_and_back
8 def dist(input, other, p=2):
9     return ivy.vector_norm(ivy.subtract(input, other), ord=p)
10 
11 
12 @to_ivy_arrays_and_back
13 def argmax(input, dim=None, keepdim=False):
14     return ivy.argmax(input, axis=dim, keepdims=keepdim)
15 
16 
17 @to_ivy_arrays_and_back
18 def argmin(input, dim=None, keepdim=False):
19     return ivy.argmin(input, axis=dim, keepdims=keepdim).astype(ivy.int64)
20 
21 
22 @to_ivy_arrays_and_back
23 def amax(input, dim=None, keepdim=False, *, out=None):
24     return ivy.max(input, axis=dim, keepdims=keepdim, out=out)
25 
26 
27 @to_ivy_arrays_and_back
28 def amin(input, dim=None, keepdim=False, *, out=None):
29     return ivy.min(input, axis=dim, keepdims=keepdim, out=out)
30 
31 
32 @to_ivy_arrays_and_back
33 def all(input, dim=None, keepdim=False, *, out=None):
34     input_dtype = ivy.as_ivy_dtype(input.dtype)
35     ret = ivy.all(input, axis=dim, keepdims=keepdim, out=out)
36     if ivy.is_uint_dtype(input_dtype):
37         ret = ivy.astype(ret, input_dtype, out=out)
38     return ret
39 
40 
41 @to_ivy_arrays_and_back
42 def any(input, dim=None, keepdim=False, *, out=None):
43     input_dtype = ivy.as_ivy_dtype(input.dtype)
44     ret = ivy.any(input, axis=dim, keepdims=keepdim, out=out)
45     if ivy.is_uint_dtype(input_dtype):
46         ret = ivy.astype(ret, input_dtype, out=out)
47     return ret
48 
49 
50 @to_ivy_arrays_and_back
51 def sum(input, dim=None, keepdim=False, *, out=None):
52     return ivy.sum(input, axis=dim, keepdims=keepdim, out=out)
53 
54 
55 @to_ivy_arrays_and_back
56 def mean(input, dim, keepdim=False, *, out=None):
57     return ivy.mean(input, axis=dim, keepdims=keepdim, out=out)
58 
59 
60 @to_ivy_arrays_and_back
61 def nanmean(input, dim=None, keepdim=False, *, dtype=None, out=None):
62     return ivy.nanmean(input, axis=dim, keepdims=keepdim, dtype=dtype, out=out)
63 
64 
65 @to_ivy_arrays_and_back
66 def std(input, dim, unbiased, keepdim=False, *, out=None):
67     return ivy.std(input, axis=dim, correction=int(unbiased), keepdims=keepdim, out=out)
68 
69 
70 @to_ivy_arrays_and_back
71 @with_unsupported_dtypes(
72     {
73         "1.11.0 and below": (
74             "float16",
75             "bfloat16",
76         )
77     },
78     "torch",
79 )
80 # TODO: the original torch.prod places * right before `dtype`
81 def prod(input, dim, *, keepdim=False, dtype=None):
82     if not dtype:
83         if "int" in input.dtype:
84             dtype = ivy.int64
85         elif "float" in input.dtype:
86             dtype = ivy.float32
87     return ivy.prod(input, axis=dim, dtype=dtype, keepdims=keepdim)
88 
89 
90 @to_ivy_arrays_and_back
91 def var(input, dim, unbiased, keepdim=False, *, out=None):
92     return ivy.var(input, axis=dim, correction=int(unbiased), keepdims=keepdim, out=out)
93 
94 
95 @to_ivy_arrays_and_back
96 def min(input, dim=None, keepdim=False, *, out=None):
97     if dim is None:
98         return ivy.min(input, axis=dim, keepdims=keepdim, out=out)
99     elif out is not None:
100         ivy.min(input, axis=dim, keepdims=keepdim, out=out[0])
101         ivy.argmin(input, axis=dim, keepdims=keepdim, out=out[1])
102         return out
103     else:
104         min_tuple = namedtuple("min", ["values", "indices"])
105         return min_tuple(
106             ivy.min(input, axis=dim, keepdims=keepdim),
107             ivy.argmin(input, axis=dim, keepdims=keepdim),
108         )
109 
110 
111 @to_ivy_arrays_and_back
112 def max(input, dim=None, keepdim=False, *, out=None):
113     if dim is None:
114         return ivy.max(input, axis=dim, keepdims=keepdim, out=out)
115     elif out is not None:
116         ivy.max(input, axis=dim, keepdims=keepdim, out=out[0])
117         ivy.argmax(input, axis=dim, keepdims=keepdim, out=out[1])
118         return out
119     else:
120         max_tuple = namedtuple("max", ["values", "indices"])
121         return max_tuple(
122             ivy.max(input, axis=dim, keepdims=keepdim),
123             ivy.argmax(input, axis=dim, keepdims=keepdim),
124         )
125 
126 
127 @to_ivy_arrays_and_back
128 def moveaxis(input, source, destination):
129     return ivy.moveaxis(input, source, destination)
130 
131 
132 @to_ivy_arrays_and_back
133 def std_mean(input, dim, unbiased, keepdim=False, *, out=None):
134     temp_std = ivy.std(
135         input, axis=dim, correction=int(unbiased), keepdims=keepdim, out=out
136     )
137     temp_mean = ivy.mean(input, axis=dim, keepdims=keepdim, out=out)
138     return temp_std, temp_mean
139 
140 
141 @to_ivy_arrays_and_back
142 def var_mean(input, dim, unbiased, keepdim=False, *, out=None):
143     temp_var = ivy.var(
144         input, axis=dim, correction=int(unbiased), keepdims=keepdim, out=out
145     )
146     temp_mean = ivy.mean(input, axis=dim, keepdims=keepdim, out=out)
147     return (temp_var, temp_mean)
148 
149 
150 @to_ivy_arrays_and_back
151 def aminmax(input, *, dim=None, keepdim=False, out=None):
152     minmax_tuple = namedtuple("minmax", ["min", "max"])
153     return minmax_tuple(
154         ivy.min(input, axis=dim, keepdims=keepdim, out=out),
155         ivy.max(input, axis=dim, keepdims=keepdim, out=out),
156     )
157 
158 
159 aminmax.unsupported_dtypes = {
160     "torch": ("float16", "bfloat16"),
161     "numpy": ("float16", "bfloat16"),
162     "jax": ("float16", "bfloat16"),
163     "tensorflow": ("float16", "bfloat16"),
164 }
165 
166 
167 @to_ivy_arrays_and_back
168 def quantile(input, q, dim=None, keepdim=False, *, interpolation="linear", out=None):
169     return ivy.quantile(
170         input, q, axis=dim, keepdims=keepdim, interpolation=interpolation, out=out
171     )
172 
173 
174 quantile.unsupported_dtypes = {
175     "torch": ("float16", "bfloat16"),
176     "numpy": ("float16", "bfloat16"),
177     "jax": ("float16", "bfloat16"),
178     "tensorflow": ("float16", "bfloat16"),
179 }
180 
181 
182 @to_ivy_arrays_and_back
183 def count_nonzero(input, dim=None):
184     return ivy.count_nonzero(input, axis=dim).astype(ivy.int64)
185
```
--- 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/ivy/functional/frontends/torch/reduction_ops.py b/ivy/functional/frontends/torch/reduction_ops.py
--- a/ivy/functional/frontends/torch/reduction_ops.py
+++ b/ivy/functional/frontends/torch/reduction_ops.py
@@ -62,6 +62,34 @@
     return ivy.nanmean(input, axis=dim, keepdims=keepdim, dtype=dtype, out=out)
 
 
+@to_ivy_arrays_and_back
+def median(input, dim=None, keepdim=False, *, out=None):
+    if dim is None:
+        input = ivy.reshape(input, (-1,))
+        sorted_input = ivy.sort(input)
+        return sorted_input[(sorted_input.shape[0] - 1) // 2]
+
+    median_tuple = namedtuple("median", ["values", "indices"])
+
+    if input.ndim == 0:
+        result = median_tuple(input, ivy.array(0))
+    else:
+        sorted_indices = ivy.argsort(input, axis=dim)
+        median_indices = ivy.gather(sorted_indices, (sorted_indices.shape[dim] - 1) // 2, axis=dim)
+        median_values = ivy.take_along_axis(input, ivy.expand_dims(median_indices, axis=dim), dim).squeeze(dim)
+
+        if keepdim:
+            median_values = ivy.expand_dims(median_values, axis=dim)
+            median_indices = ivy.expand_dims(median_indices, axis=dim)
+
+        result = median_tuple(median_values, median_indices)
+    if out is not None:
+        ivy.inplace_update(out[0], result.values)
+        ivy.inplace_update(out[1], result.indices)
+        return out
+    return result
+
+
 @to_ivy_arrays_and_back
 def std(input, dim, unbiased, keepdim=False, *, out=None):
     return ivy.std(input, axis=dim, correction=int(unbiased), keepdims=keepdim, out=out)

{"golden_diff": "diff --git a/ivy/functional/frontends/torch/reduction_ops.py b/ivy/functional/frontends/torch/reduction_ops.py\n--- a/ivy/functional/frontends/torch/reduction_ops.py\n+++ b/ivy/functional/frontends/torch/reduction_ops.py\n@@ -62,6 +62,34 @@\n     return ivy.nanmean(input, axis=dim, keepdims=keepdim, dtype=dtype, out=out)\r\n \r\n \r\n+@to_ivy_arrays_and_back\r\n+def median(input, dim=None, keepdim=False, *, out=None):\r\n+    if dim is None:\r\n+        input = ivy.reshape(input, (-1,))\r\n+        sorted_input = ivy.sort(input)\r\n+        return sorted_input[(sorted_input.shape[0] - 1) // 2]\r\n+\r\n+    median_tuple = namedtuple(\"median\", [\"values\", \"indices\"])\r\n+\r\n+    if input.ndim == 0:\r\n+        result = median_tuple(input, ivy.array(0))\r\n+    else:\r\n+        sorted_indices = ivy.argsort(input, axis=dim)\r\n+        median_indices = ivy.gather(sorted_indices, (sorted_indices.shape[dim] - 1) // 2, axis=dim)\r\n+        median_values = ivy.take_along_axis(input, ivy.expand_dims(median_indices, axis=dim), dim).squeeze(dim)\r\n+\r\n+        if keepdim:\r\n+            median_values = ivy.expand_dims(median_values, axis=dim)\r\n+            median_indices = ivy.expand_dims(median_indices, axis=dim)\r\n+\r\n+        result = median_tuple(median_values, median_indices)\r\n+    if out is not None:\r\n+        ivy.inplace_update(out[0], result.values)\r\n+        ivy.inplace_update(out[1], result.indices)\r\n+        return out\r\n+    return result\r\n+\r\n+\r\n @to_ivy_arrays_and_back\r\n def std(input, dim, unbiased, keepdim=False, *, out=None):\r\n     return ivy.std(input, axis=dim, correction=int(unbiased), keepdims=keepdim, out=out)\n", "issue": "median\nThe PyTorch front end median function implemented in #13212 does not follow the correct behaviour. PyTorch's median returns a named tuple with the median and their indices when a axis is provided to reduce along. The incorrect implementation has been reverted in #13480 \r\n\r\nhttps://pytorch.org/docs/stable/generated/torch.median.html\n", "before_files": [{"content": "import ivy\r\nfrom ivy.func_wrapper import with_unsupported_dtypes\r\nfrom ivy.functional.frontends.torch.func_wrapper import to_ivy_arrays_and_back\r\nfrom collections import namedtuple\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef dist(input, other, p=2):\r\n    return ivy.vector_norm(ivy.subtract(input, other), ord=p)\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef argmax(input, dim=None, keepdim=False):\r\n    return ivy.argmax(input, axis=dim, keepdims=keepdim)\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef argmin(input, dim=None, keepdim=False):\r\n    return ivy.argmin(input, axis=dim, keepdims=keepdim).astype(ivy.int64)\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef amax(input, dim=None, keepdim=False, *, out=None):\r\n    return ivy.max(input, axis=dim, keepdims=keepdim, out=out)\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef amin(input, dim=None, keepdim=False, *, out=None):\r\n    return ivy.min(input, axis=dim, keepdims=keepdim, out=out)\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef all(input, dim=None, keepdim=False, *, out=None):\r\n    input_dtype = ivy.as_ivy_dtype(input.dtype)\r\n    ret = ivy.all(input, axis=dim, keepdims=keepdim, out=out)\r\n    if ivy.is_uint_dtype(input_dtype):\r\n        ret = ivy.astype(ret, input_dtype, out=out)\r\n    return ret\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef any(input, dim=None, keepdim=False, *, out=None):\r\n    input_dtype = ivy.as_ivy_dtype(input.dtype)\r\n    ret = ivy.any(input, axis=dim, keepdims=keepdim, out=out)\r\n    if ivy.is_uint_dtype(input_dtype):\r\n        ret = ivy.astype(ret, input_dtype, out=out)\r\n    return ret\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef sum(input, dim=None, keepdim=False, *, out=None):\r\n    return ivy.sum(input, axis=dim, keepdims=keepdim, out=out)\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef mean(input, dim, keepdim=False, *, out=None):\r\n    return ivy.mean(input, axis=dim, keepdims=keepdim, out=out)\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef nanmean(input, dim=None, keepdim=False, *, dtype=None, out=None):\r\n    return ivy.nanmean(input, axis=dim, keepdims=keepdim, dtype=dtype, out=out)\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef std(input, dim, unbiased, keepdim=False, *, out=None):\r\n    return ivy.std(input, axis=dim, correction=int(unbiased), keepdims=keepdim, out=out)\r\n\r\n\r\n@to_ivy_arrays_and_back\r\n@with_unsupported_dtypes(\r\n    {\r\n        \"1.11.0 and below\": (\r\n            \"float16\",\r\n            \"bfloat16\",\r\n        )\r\n    },\r\n    \"torch\",\r\n)\r\n# TODO: the original torch.prod places * right before `dtype`\r\ndef prod(input, dim, *, keepdim=False, dtype=None):\r\n    if not dtype:\r\n        if \"int\" in input.dtype:\r\n            dtype = ivy.int64\r\n        elif \"float\" in input.dtype:\r\n            dtype = ivy.float32\r\n    return ivy.prod(input, axis=dim, dtype=dtype, keepdims=keepdim)\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef var(input, dim, unbiased, keepdim=False, *, out=None):\r\n    return ivy.var(input, axis=dim, correction=int(unbiased), keepdims=keepdim, out=out)\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef min(input, dim=None, keepdim=False, *, out=None):\r\n    if dim is None:\r\n        return ivy.min(input, axis=dim, keepdims=keepdim, out=out)\r\n    elif out is not None:\r\n        ivy.min(input, axis=dim, keepdims=keepdim, out=out[0])\r\n        ivy.argmin(input, axis=dim, keepdims=keepdim, out=out[1])\r\n        return out\r\n    else:\r\n        min_tuple = namedtuple(\"min\", [\"values\", \"indices\"])\r\n        return min_tuple(\r\n            ivy.min(input, axis=dim, keepdims=keepdim),\r\n            ivy.argmin(input, axis=dim, keepdims=keepdim),\r\n        )\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef max(input, dim=None, keepdim=False, *, out=None):\r\n    if dim is None:\r\n        return ivy.max(input, axis=dim, keepdims=keepdim, out=out)\r\n    elif out is not None:\r\n        ivy.max(input, axis=dim, keepdims=keepdim, out=out[0])\r\n        ivy.argmax(input, axis=dim, keepdims=keepdim, out=out[1])\r\n        return out\r\n    else:\r\n        max_tuple = namedtuple(\"max\", [\"values\", \"indices\"])\r\n        return max_tuple(\r\n            ivy.max(input, axis=dim, keepdims=keepdim),\r\n            ivy.argmax(input, axis=dim, keepdims=keepdim),\r\n        )\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef moveaxis(input, source, destination):\r\n    return ivy.moveaxis(input, source, destination)\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef std_mean(input, dim, unbiased, keepdim=False, *, out=None):\r\n    temp_std = ivy.std(\r\n        input, axis=dim, correction=int(unbiased), keepdims=keepdim, out=out\r\n    )\r\n    temp_mean = ivy.mean(input, axis=dim, keepdims=keepdim, out=out)\r\n    return temp_std, temp_mean\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef var_mean(input, dim, unbiased, keepdim=False, *, out=None):\r\n    temp_var = ivy.var(\r\n        input, axis=dim, correction=int(unbiased), keepdims=keepdim, out=out\r\n    )\r\n    temp_mean = ivy.mean(input, axis=dim, keepdims=keepdim, out=out)\r\n    return (temp_var, temp_mean)\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef aminmax(input, *, dim=None, keepdim=False, out=None):\r\n    minmax_tuple = namedtuple(\"minmax\", [\"min\", \"max\"])\r\n    return minmax_tuple(\r\n        ivy.min(input, axis=dim, keepdims=keepdim, out=out),\r\n        ivy.max(input, axis=dim, keepdims=keepdim, out=out),\r\n    )\r\n\r\n\r\naminmax.unsupported_dtypes = {\r\n    \"torch\": (\"float16\", \"bfloat16\"),\r\n    \"numpy\": (\"float16\", \"bfloat16\"),\r\n    \"jax\": (\"float16\", \"bfloat16\"),\r\n    \"tensorflow\": (\"float16\", \"bfloat16\"),\r\n}\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef quantile(input, q, dim=None, keepdim=False, *, interpolation=\"linear\", out=None):\r\n    return ivy.quantile(\r\n        input, q, axis=dim, keepdims=keepdim, interpolation=interpolation, out=out\r\n    )\r\n\r\n\r\nquantile.unsupported_dtypes = {\r\n    \"torch\": (\"float16\", \"bfloat16\"),\r\n    \"numpy\": (\"float16\", \"bfloat16\"),\r\n    \"jax\": (\"float16\", \"bfloat16\"),\r\n    \"tensorflow\": (\"float16\", \"bfloat16\"),\r\n}\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef count_nonzero(input, dim=None):\r\n    return ivy.count_nonzero(input, axis=dim).astype(ivy.int64)\r\n", "path": "ivy/functional/frontends/torch/reduction_ops.py"}], "after_files": [{"content": "import ivy\r\nfrom ivy.func_wrapper import with_unsupported_dtypes\r\nfrom ivy.functional.frontends.torch.func_wrapper import to_ivy_arrays_and_back\r\nfrom collections import namedtuple\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef dist(input, other, p=2):\r\n    return ivy.vector_norm(ivy.subtract(input, other), ord=p)\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef argmax(input, dim=None, keepdim=False):\r\n    return ivy.argmax(input, axis=dim, keepdims=keepdim)\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef argmin(input, dim=None, keepdim=False):\r\n    return ivy.argmin(input, axis=dim, keepdims=keepdim).astype(ivy.int64)\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef amax(input, dim=None, keepdim=False, *, out=None):\r\n    return ivy.max(input, axis=dim, keepdims=keepdim, out=out)\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef amin(input, dim=None, keepdim=False, *, out=None):\r\n    return ivy.min(input, axis=dim, keepdims=keepdim, out=out)\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef all(input, dim=None, keepdim=False, *, out=None):\r\n    input_dtype = ivy.as_ivy_dtype(input.dtype)\r\n    ret = ivy.all(input, axis=dim, keepdims=keepdim, out=out)\r\n    if ivy.is_uint_dtype(input_dtype):\r\n        ret = ivy.astype(ret, input_dtype, out=out)\r\n    return ret\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef any(input, dim=None, keepdim=False, *, out=None):\r\n    input_dtype = ivy.as_ivy_dtype(input.dtype)\r\n    ret = ivy.any(input, axis=dim, keepdims=keepdim, out=out)\r\n    if ivy.is_uint_dtype(input_dtype):\r\n        ret = ivy.astype(ret, input_dtype, out=out)\r\n    return ret\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef sum(input, dim=None, keepdim=False, *, out=None):\r\n    return ivy.sum(input, axis=dim, keepdims=keepdim, out=out)\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef mean(input, dim, keepdim=False, *, out=None):\r\n    return ivy.mean(input, axis=dim, keepdims=keepdim, out=out)\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef nanmean(input, dim=None, keepdim=False, *, dtype=None, out=None):\r\n    return ivy.nanmean(input, axis=dim, keepdims=keepdim, dtype=dtype, out=out)\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef median(input, dim=None, keepdim=False, *, out=None):\r\n    if dim is None:\r\n        input = ivy.reshape(input, (-1,))\r\n        sorted_input = ivy.sort(input)\r\n        return sorted_input[(sorted_input.shape[0] - 1) // 2]\r\n\r\n    median_tuple = namedtuple(\"median\", [\"values\", \"indices\"])\r\n\r\n    if input.ndim == 0:\r\n        result = median_tuple(input, ivy.array(0))\r\n    else:\r\n        sorted_indices = ivy.argsort(input, axis=dim)\r\n        median_indices = ivy.gather(sorted_indices, (sorted_indices.shape[dim] - 1) // 2, axis=dim)\r\n        median_values = ivy.take_along_axis(input, ivy.expand_dims(median_indices, axis=dim), dim).squeeze(dim)\r\n\r\n        if keepdim:\r\n            median_values = ivy.expand_dims(median_values, axis=dim)\r\n            median_indices = ivy.expand_dims(median_indices, axis=dim)\r\n\r\n        result = median_tuple(median_values, median_indices)\r\n    if out is not None:\r\n        ivy.inplace_update(out[0], result.values)\r\n        ivy.inplace_update(out[1], result.indices)\r\n        return out\r\n    return result\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef std(input, dim, unbiased, keepdim=False, *, out=None):\r\n    return ivy.std(input, axis=dim, correction=int(unbiased), keepdims=keepdim, out=out)\r\n\r\n\r\n@to_ivy_arrays_and_back\r\n@with_unsupported_dtypes(\r\n    {\r\n        \"1.11.0 and below\": (\r\n            \"float16\",\r\n            \"bfloat16\",\r\n        )\r\n    },\r\n    \"torch\",\r\n)\r\n# TODO: the original torch.prod places * right before `dtype`\r\ndef prod(input, dim, *, keepdim=False, dtype=None):\r\n    if not dtype:\r\n        if \"int\" in input.dtype:\r\n            dtype = ivy.int64\r\n        elif \"float\" in input.dtype:\r\n            dtype = ivy.float32\r\n    return ivy.prod(input, axis=dim, dtype=dtype, keepdims=keepdim)\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef var(input, dim, unbiased, keepdim=False, *, out=None):\r\n    return ivy.var(input, axis=dim, correction=int(unbiased), keepdims=keepdim, out=out)\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef min(input, dim=None, keepdim=False, *, out=None):\r\n    if dim is None:\r\n        return ivy.min(input, axis=dim, keepdims=keepdim, out=out)\r\n    elif out is not None:\r\n        ivy.min(input, axis=dim, keepdims=keepdim, out=out[0])\r\n        ivy.argmin(input, axis=dim, keepdims=keepdim, out=out[1])\r\n        return out\r\n    else:\r\n        min_tuple = namedtuple(\"min\", [\"values\", \"indices\"])\r\n        return min_tuple(\r\n            ivy.min(input, axis=dim, keepdims=keepdim),\r\n            ivy.argmin(input, axis=dim, keepdims=keepdim),\r\n        )\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef max(input, dim=None, keepdim=False, *, out=None):\r\n    if dim is None:\r\n        return ivy.max(input, axis=dim, keepdims=keepdim, out=out)\r\n    elif out is not None:\r\n        ivy.max(input, axis=dim, keepdims=keepdim, out=out[0])\r\n        ivy.argmax(input, axis=dim, keepdims=keepdim, out=out[1])\r\n        return out\r\n    else:\r\n        max_tuple = namedtuple(\"max\", [\"values\", \"indices\"])\r\n        return max_tuple(\r\n            ivy.max(input, axis=dim, keepdims=keepdim),\r\n            ivy.argmax(input, axis=dim, keepdims=keepdim),\r\n        )\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef moveaxis(input, source, destination):\r\n    return ivy.moveaxis(input, source, destination)\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef std_mean(input, dim, unbiased, keepdim=False, *, out=None):\r\n    temp_std = ivy.std(\r\n        input, axis=dim, correction=int(unbiased), keepdims=keepdim, out=out\r\n    )\r\n    temp_mean = ivy.mean(input, axis=dim, keepdims=keepdim, out=out)\r\n    return temp_std, temp_mean\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef var_mean(input, dim, unbiased, keepdim=False, *, out=None):\r\n    temp_var = ivy.var(\r\n        input, axis=dim, correction=int(unbiased), keepdims=keepdim, out=out\r\n    )\r\n    temp_mean = ivy.mean(input, axis=dim, keepdims=keepdim, out=out)\r\n    return (temp_var, temp_mean)\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef aminmax(input, *, dim=None, keepdim=False, out=None):\r\n    minmax_tuple = namedtuple(\"minmax\", [\"min\", \"max\"])\r\n    return minmax_tuple(\r\n        ivy.min(input, axis=dim, keepdims=keepdim, out=out),\r\n        ivy.max(input, axis=dim, keepdims=keepdim, out=out),\r\n    )\r\n\r\n\r\naminmax.unsupported_dtypes = {\r\n    \"torch\": (\"float16\", \"bfloat16\"),\r\n    \"numpy\": (\"float16\", \"bfloat16\"),\r\n    \"jax\": (\"float16\", \"bfloat16\"),\r\n    \"tensorflow\": (\"float16\", \"bfloat16\"),\r\n}\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef quantile(input, q, dim=None, keepdim=False, *, interpolation=\"linear\", out=None):\r\n    return ivy.quantile(\r\n        input, q, axis=dim, keepdims=keepdim, interpolation=interpolation, out=out\r\n    )\r\n\r\n\r\nquantile.unsupported_dtypes = {\r\n    \"torch\": (\"float16\", \"bfloat16\"),\r\n    \"numpy\": (\"float16\", \"bfloat16\"),\r\n    \"jax\": (\"float16\", \"bfloat16\"),\r\n    \"tensorflow\": (\"float16\", \"bfloat16\"),\r\n}\r\n\r\n\r\n@to_ivy_arrays_and_back\r\ndef count_nonzero(input, dim=None):\r\n    return ivy.count_nonzero(input, axis=dim).astype(ivy.int64)\r\n", "path": "ivy/functional/frontends/torch/reduction_ops.py"}]}