We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
lp_pool2d


--- 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/nn/functional/pooling_functions.py`
Content:
```
1 # global
2 
3 # local
4 import ivy
5 from ivy import with_unsupported_dtypes
6 from ivy.functional.frontends.tensorflow.func_wrapper import (
7     to_ivy_arrays_and_back,
8 )
9 
10 
11 def _broadcast_pooling_helper(x, pool_dims: str = "2d", name: str = "padding"):
12     dims = {"1d": 1, "2d": 2, "3d": 3}
13 
14     if isinstance(x, int):
15         return tuple([x for _ in range(dims[pool_dims])])
16 
17     if len(x) == 1:
18         return tuple([x[0] for _ in range(dims[pool_dims])])
19     elif len(x) == dims[pool_dims]:
20         return tuple(x)
21     elif len(x) != dims[pool_dims]:
22         raise ValueError(
23             f"`{name}` must either be a single int, "
24             f"or a tuple of {dims[pool_dims]} ints. "
25         )
26 
27 
28 @to_ivy_arrays_and_back
29 def avg_pool1d(
30     input, kernel_size, stride=None, padding=0, ceil_mode=False, count_include_pad=True
31 ):
32     kernel_size = _broadcast_pooling_helper(kernel_size, "1d", name="kernel_size")
33     stride = _broadcast_pooling_helper(stride, "1d", name="stride")
34     padding = _broadcast_pooling_helper(padding, "1d", name="padding")
35     kernel_pads = list(zip(kernel_size, padding))
36 
37     data_format = "NCW"
38 
39     if not all([pad <= kernel / 2 for kernel, pad in kernel_pads]):
40         raise ValueError(
41             "pad should be smaller than or equal to half of kernel size, "
42             f"but got padding={padding}, kernel_size={kernel_size}. "
43         )
44     # figure out whether to apply padding
45     if all([pad == ivy.ceil((kernel - 1) / 2) for kernel, pad in kernel_pads]):
46         padding_str = "SAME"
47     else:
48         padding_str = "VALID"
49 
50     return ivy.avg_pool1d(
51         input, kernel_size, stride, padding_str, data_format=data_format
52     )
53 
54 
55 @to_ivy_arrays_and_back
56 def avg_pool2d(
57     input,
58     kernel_size,
59     stride=None,
60     padding=0,
61     ceil_mode=False,
62     count_include_pad=True,
63     divisor_override=None,
64 ):
65     # Figure out input dims N
66     input_rank = input.ndim
67 
68     if input_rank == 3:
69         # CHW
70         data_format = "CHW"
71     elif input_rank == 4:
72         # NCHW
73         data_format = "NCHW"
74 
75     kernel_size = _broadcast_pooling_helper(kernel_size, "2d", name="kernel_size")
76     stride = _broadcast_pooling_helper(stride, "2d", name="stride")
77     padding = _broadcast_pooling_helper(padding, "2d", name="padding")
78     kernel_pads = list(zip(kernel_size, padding))
79 
80     # Padding should be less than or equal to half of kernel size
81     if not all([pad <= kernel / 2 for kernel, pad in kernel_pads]):
82         raise ValueError(
83             "pad should be smaller than or equal to half of kernel size, "
84             f"but got padding={padding}, kernel_size={kernel_size}. "
85         )
86 
87     # Figure out padding string
88     if all([pad == ivy.ceil((kernel - 1) / 2) for kernel, pad in kernel_pads]):
89         padding_str = "SAME"
90     else:
91         padding_str = "VALID"
92 
93     return ivy.avg_pool2d(
94         input,
95         kernel_size,
96         stride,
97         padding_str,
98         data_format=data_format,
99     )
100 
101 
102 @with_unsupported_dtypes({"1.11.0 and below": ("float16",)}, "torch")
103 @to_ivy_arrays_and_back
104 def max_pool2d(
105     input,
106     kernel_size,
107     stride=None,
108     padding=0,
109     dilation=1,
110     ceil_mode=False,
111     return_indices=False,
112 ):
113     # ToDo: Add return_indices once superset in implemented
114     dim_check = False
115     if input.ndim == 3:
116         input = input.expand_dims()
117         dim_check = True
118     if not stride:
119         stride = kernel_size
120     ret = ivy.max_pool2d(
121         input,
122         kernel_size,
123         stride,
124         padding,
125         data_format="NCHW",
126         dilation=dilation,
127         ceil_mode=ceil_mode,
128     )
129     if dim_check:
130         return ret.squeeze(0)
131     return ret
132 
133 
134 @with_unsupported_dtypes(
135     {
136         "1.11.0 and below": (
137             "bfloat16",
138             "float16",
139         )
140     },
141     "torch",
142 )
143 @to_ivy_arrays_and_back
144 def adaptive_avg_pool1d(input, output_size):
145     return ivy.adaptive_avg_pool1d(input, output_size)
146 
147 
148 @with_unsupported_dtypes(
149     {
150         "1.11.0 and below": (
151             "float16",
152             "bfloat16",
153         )
154     },
155     "torch",
156 )
157 @to_ivy_arrays_and_back
158 def adaptive_avg_pool2d(input, output_size):
159     return ivy.adaptive_avg_pool2d(input, output_size)
160 
161 
162 @with_unsupported_dtypes(
163     {
164         "1.11.0 and below": (
165             "float16",
166             "bfloat16",
167         )
168     },
169     "torch",
170 )
171 @to_ivy_arrays_and_back
172 def lp_pool1d(input, norm_type, kernel_size, stride=None, ceil_mode=False):
173 
174     data_format = "NCW"
175     padding = "VALID"
176     if stride is not None:
177         out = ivy.avg_pool1d(
178             ivy.pow(input, norm_type),
179             kernel_size,
180             stride,
181             padding,
182             data_format=data_format,
183         )
184     else:
185         out = ivy.avg_pool1d(
186             ivy.pow(input, norm_type),
187             kernel_size,
188             kernel_size,
189             padding,
190             data_format=data_format,
191         )
192 
193     return ivy.pow(ivy.multiply(out, kernel_size), ivy.divide(1.0, norm_type))
194
```
--- 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/nn/functional/pooling_functions.py b/ivy/functional/frontends/torch/nn/functional/pooling_functions.py
--- a/ivy/functional/frontends/torch/nn/functional/pooling_functions.py
+++ b/ivy/functional/frontends/torch/nn/functional/pooling_functions.py
@@ -191,3 +191,29 @@
         )
 
     return ivy.pow(ivy.multiply(out, kernel_size), ivy.divide(1.0, norm_type))
+
+
+@to_ivy_arrays_and_back
+def lp_pool2d(input, norm_type, kernel_size, stride=None, ceil_mode=False):
+
+    data_format = "NCHW"
+    padding = "VALID"
+    if stride is not None:
+        out = ivy.avg_pool2d(
+            ivy.pow(input, norm_type),
+            kernel_size,
+            stride,
+            padding,
+            data_format=data_format,
+        )
+    else:
+        out = ivy.avg_pool2d(
+            ivy.pow(input, norm_type),
+            kernel_size,
+            kernel_size,
+            padding,
+            data_format=data_format,
+        )
+    if not isinstance(kernel_size, int):
+        kernel_size = kernel_size[0] * kernel_size[1]
+    return ivy.pow(ivy.multiply(out, kernel_size), ivy.divide(1.0, norm_type))

{"golden_diff": "diff --git a/ivy/functional/frontends/torch/nn/functional/pooling_functions.py b/ivy/functional/frontends/torch/nn/functional/pooling_functions.py\n--- a/ivy/functional/frontends/torch/nn/functional/pooling_functions.py\n+++ b/ivy/functional/frontends/torch/nn/functional/pooling_functions.py\n@@ -191,3 +191,29 @@\n         )\n \n     return ivy.pow(ivy.multiply(out, kernel_size), ivy.divide(1.0, norm_type))\n+\n+\n+@to_ivy_arrays_and_back\n+def lp_pool2d(input, norm_type, kernel_size, stride=None, ceil_mode=False):\n+\n+    data_format = \"NCHW\"\n+    padding = \"VALID\"\n+    if stride is not None:\n+        out = ivy.avg_pool2d(\n+            ivy.pow(input, norm_type),\n+            kernel_size,\n+            stride,\n+            padding,\n+            data_format=data_format,\n+        )\n+    else:\n+        out = ivy.avg_pool2d(\n+            ivy.pow(input, norm_type),\n+            kernel_size,\n+            kernel_size,\n+            padding,\n+            data_format=data_format,\n+        )\n+    if not isinstance(kernel_size, int):\n+        kernel_size = kernel_size[0] * kernel_size[1]\n+    return ivy.pow(ivy.multiply(out, kernel_size), ivy.divide(1.0, norm_type))\n", "issue": "lp_pool2d\n\n", "before_files": [{"content": "# global\n\n# local\nimport ivy\nfrom ivy import with_unsupported_dtypes\nfrom ivy.functional.frontends.tensorflow.func_wrapper import (\n    to_ivy_arrays_and_back,\n)\n\n\ndef _broadcast_pooling_helper(x, pool_dims: str = \"2d\", name: str = \"padding\"):\n    dims = {\"1d\": 1, \"2d\": 2, \"3d\": 3}\n\n    if isinstance(x, int):\n        return tuple([x for _ in range(dims[pool_dims])])\n\n    if len(x) == 1:\n        return tuple([x[0] for _ in range(dims[pool_dims])])\n    elif len(x) == dims[pool_dims]:\n        return tuple(x)\n    elif len(x) != dims[pool_dims]:\n        raise ValueError(\n            f\"`{name}` must either be a single int, \"\n            f\"or a tuple of {dims[pool_dims]} ints. \"\n        )\n\n\n@to_ivy_arrays_and_back\ndef avg_pool1d(\n    input, kernel_size, stride=None, padding=0, ceil_mode=False, count_include_pad=True\n):\n    kernel_size = _broadcast_pooling_helper(kernel_size, \"1d\", name=\"kernel_size\")\n    stride = _broadcast_pooling_helper(stride, \"1d\", name=\"stride\")\n    padding = _broadcast_pooling_helper(padding, \"1d\", name=\"padding\")\n    kernel_pads = list(zip(kernel_size, padding))\n\n    data_format = \"NCW\"\n\n    if not all([pad <= kernel / 2 for kernel, pad in kernel_pads]):\n        raise ValueError(\n            \"pad should be smaller than or equal to half of kernel size, \"\n            f\"but got padding={padding}, kernel_size={kernel_size}. \"\n        )\n    # figure out whether to apply padding\n    if all([pad == ivy.ceil((kernel - 1) / 2) for kernel, pad in kernel_pads]):\n        padding_str = \"SAME\"\n    else:\n        padding_str = \"VALID\"\n\n    return ivy.avg_pool1d(\n        input, kernel_size, stride, padding_str, data_format=data_format\n    )\n\n\n@to_ivy_arrays_and_back\ndef avg_pool2d(\n    input,\n    kernel_size,\n    stride=None,\n    padding=0,\n    ceil_mode=False,\n    count_include_pad=True,\n    divisor_override=None,\n):\n    # Figure out input dims N\n    input_rank = input.ndim\n\n    if input_rank == 3:\n        # CHW\n        data_format = \"CHW\"\n    elif input_rank == 4:\n        # NCHW\n        data_format = \"NCHW\"\n\n    kernel_size = _broadcast_pooling_helper(kernel_size, \"2d\", name=\"kernel_size\")\n    stride = _broadcast_pooling_helper(stride, \"2d\", name=\"stride\")\n    padding = _broadcast_pooling_helper(padding, \"2d\", name=\"padding\")\n    kernel_pads = list(zip(kernel_size, padding))\n\n    # Padding should be less than or equal to half of kernel size\n    if not all([pad <= kernel / 2 for kernel, pad in kernel_pads]):\n        raise ValueError(\n            \"pad should be smaller than or equal to half of kernel size, \"\n            f\"but got padding={padding}, kernel_size={kernel_size}. \"\n        )\n\n    # Figure out padding string\n    if all([pad == ivy.ceil((kernel - 1) / 2) for kernel, pad in kernel_pads]):\n        padding_str = \"SAME\"\n    else:\n        padding_str = \"VALID\"\n\n    return ivy.avg_pool2d(\n        input,\n        kernel_size,\n        stride,\n        padding_str,\n        data_format=data_format,\n    )\n\n\n@with_unsupported_dtypes({\"1.11.0 and below\": (\"float16\",)}, \"torch\")\n@to_ivy_arrays_and_back\ndef max_pool2d(\n    input,\n    kernel_size,\n    stride=None,\n    padding=0,\n    dilation=1,\n    ceil_mode=False,\n    return_indices=False,\n):\n    # ToDo: Add return_indices once superset in implemented\n    dim_check = False\n    if input.ndim == 3:\n        input = input.expand_dims()\n        dim_check = True\n    if not stride:\n        stride = kernel_size\n    ret = ivy.max_pool2d(\n        input,\n        kernel_size,\n        stride,\n        padding,\n        data_format=\"NCHW\",\n        dilation=dilation,\n        ceil_mode=ceil_mode,\n    )\n    if dim_check:\n        return ret.squeeze(0)\n    return ret\n\n\n@with_unsupported_dtypes(\n    {\n        \"1.11.0 and below\": (\n            \"bfloat16\",\n            \"float16\",\n        )\n    },\n    \"torch\",\n)\n@to_ivy_arrays_and_back\ndef adaptive_avg_pool1d(input, output_size):\n    return ivy.adaptive_avg_pool1d(input, output_size)\n\n\n@with_unsupported_dtypes(\n    {\n        \"1.11.0 and below\": (\n            \"float16\",\n            \"bfloat16\",\n        )\n    },\n    \"torch\",\n)\n@to_ivy_arrays_and_back\ndef adaptive_avg_pool2d(input, output_size):\n    return ivy.adaptive_avg_pool2d(input, output_size)\n\n\n@with_unsupported_dtypes(\n    {\n        \"1.11.0 and below\": (\n            \"float16\",\n            \"bfloat16\",\n        )\n    },\n    \"torch\",\n)\n@to_ivy_arrays_and_back\ndef lp_pool1d(input, norm_type, kernel_size, stride=None, ceil_mode=False):\n\n    data_format = \"NCW\"\n    padding = \"VALID\"\n    if stride is not None:\n        out = ivy.avg_pool1d(\n            ivy.pow(input, norm_type),\n            kernel_size,\n            stride,\n            padding,\n            data_format=data_format,\n        )\n    else:\n        out = ivy.avg_pool1d(\n            ivy.pow(input, norm_type),\n            kernel_size,\n            kernel_size,\n            padding,\n            data_format=data_format,\n        )\n\n    return ivy.pow(ivy.multiply(out, kernel_size), ivy.divide(1.0, norm_type))\n", "path": "ivy/functional/frontends/torch/nn/functional/pooling_functions.py"}], "after_files": [{"content": "# global\n\n# local\nimport ivy\nfrom ivy import with_unsupported_dtypes\nfrom ivy.functional.frontends.tensorflow.func_wrapper import (\n    to_ivy_arrays_and_back,\n)\n\n\ndef _broadcast_pooling_helper(x, pool_dims: str = \"2d\", name: str = \"padding\"):\n    dims = {\"1d\": 1, \"2d\": 2, \"3d\": 3}\n\n    if isinstance(x, int):\n        return tuple([x for _ in range(dims[pool_dims])])\n\n    if len(x) == 1:\n        return tuple([x[0] for _ in range(dims[pool_dims])])\n    elif len(x) == dims[pool_dims]:\n        return tuple(x)\n    elif len(x) != dims[pool_dims]:\n        raise ValueError(\n            f\"`{name}` must either be a single int, \"\n            f\"or a tuple of {dims[pool_dims]} ints. \"\n        )\n\n\n@to_ivy_arrays_and_back\ndef avg_pool1d(\n    input, kernel_size, stride=None, padding=0, ceil_mode=False, count_include_pad=True\n):\n    kernel_size = _broadcast_pooling_helper(kernel_size, \"1d\", name=\"kernel_size\")\n    stride = _broadcast_pooling_helper(stride, \"1d\", name=\"stride\")\n    padding = _broadcast_pooling_helper(padding, \"1d\", name=\"padding\")\n    kernel_pads = list(zip(kernel_size, padding))\n\n    data_format = \"NCW\"\n\n    if not all([pad <= kernel / 2 for kernel, pad in kernel_pads]):\n        raise ValueError(\n            \"pad should be smaller than or equal to half of kernel size, \"\n            f\"but got padding={padding}, kernel_size={kernel_size}. \"\n        )\n    # figure out whether to apply padding\n    if all([pad == ivy.ceil((kernel - 1) / 2) for kernel, pad in kernel_pads]):\n        padding_str = \"SAME\"\n    else:\n        padding_str = \"VALID\"\n\n    return ivy.avg_pool1d(\n        input, kernel_size, stride, padding_str, data_format=data_format\n    )\n\n\n@to_ivy_arrays_and_back\ndef avg_pool2d(\n    input,\n    kernel_size,\n    stride=None,\n    padding=0,\n    ceil_mode=False,\n    count_include_pad=True,\n    divisor_override=None,\n):\n    # Figure out input dims N\n    input_rank = input.ndim\n\n    if input_rank == 3:\n        # CHW\n        data_format = \"CHW\"\n    elif input_rank == 4:\n        # NCHW\n        data_format = \"NCHW\"\n\n    kernel_size = _broadcast_pooling_helper(kernel_size, \"2d\", name=\"kernel_size\")\n    stride = _broadcast_pooling_helper(stride, \"2d\", name=\"stride\")\n    padding = _broadcast_pooling_helper(padding, \"2d\", name=\"padding\")\n    kernel_pads = list(zip(kernel_size, padding))\n\n    # Padding should be less than or equal to half of kernel size\n    if not all([pad <= kernel / 2 for kernel, pad in kernel_pads]):\n        raise ValueError(\n            \"pad should be smaller than or equal to half of kernel size, \"\n            f\"but got padding={padding}, kernel_size={kernel_size}. \"\n        )\n\n    # Figure out padding string\n    if all([pad == ivy.ceil((kernel - 1) / 2) for kernel, pad in kernel_pads]):\n        padding_str = \"SAME\"\n    else:\n        padding_str = \"VALID\"\n\n    return ivy.avg_pool2d(\n        input,\n        kernel_size,\n        stride,\n        padding_str,\n        data_format=data_format,\n    )\n\n\n@with_unsupported_dtypes({\"1.11.0 and below\": (\"float16\",)}, \"torch\")\n@to_ivy_arrays_and_back\ndef max_pool2d(\n    input,\n    kernel_size,\n    stride=None,\n    padding=0,\n    dilation=1,\n    ceil_mode=False,\n    return_indices=False,\n):\n    # ToDo: Add return_indices once superset in implemented\n    dim_check = False\n    if input.ndim == 3:\n        input = input.expand_dims()\n        dim_check = True\n    if not stride:\n        stride = kernel_size\n    ret = ivy.max_pool2d(\n        input,\n        kernel_size,\n        stride,\n        padding,\n        data_format=\"NCHW\",\n        dilation=dilation,\n        ceil_mode=ceil_mode,\n    )\n    if dim_check:\n        return ret.squeeze(0)\n    return ret\n\n\n@with_unsupported_dtypes(\n    {\n        \"1.11.0 and below\": (\n            \"bfloat16\",\n            \"float16\",\n        )\n    },\n    \"torch\",\n)\n@to_ivy_arrays_and_back\ndef adaptive_avg_pool1d(input, output_size):\n    return ivy.adaptive_avg_pool1d(input, output_size)\n\n\n@with_unsupported_dtypes(\n    {\n        \"1.11.0 and below\": (\n            \"float16\",\n            \"bfloat16\",\n        )\n    },\n    \"torch\",\n)\n@to_ivy_arrays_and_back\ndef adaptive_avg_pool2d(input, output_size):\n    return ivy.adaptive_avg_pool2d(input, output_size)\n\n\n@with_unsupported_dtypes(\n    {\n        \"1.11.0 and below\": (\n            \"float16\",\n            \"bfloat16\",\n        )\n    },\n    \"torch\",\n)\n@to_ivy_arrays_and_back\ndef lp_pool1d(input, norm_type, kernel_size, stride=None, ceil_mode=False):\n\n    data_format = \"NCW\"\n    padding = \"VALID\"\n    if stride is not None:\n        out = ivy.avg_pool1d(\n            ivy.pow(input, norm_type),\n            kernel_size,\n            stride,\n            padding,\n            data_format=data_format,\n        )\n    else:\n        out = ivy.avg_pool1d(\n            ivy.pow(input, norm_type),\n            kernel_size,\n            kernel_size,\n            padding,\n            data_format=data_format,\n        )\n\n    return ivy.pow(ivy.multiply(out, kernel_size), ivy.divide(1.0, norm_type))\n\n\n@to_ivy_arrays_and_back\ndef lp_pool2d(input, norm_type, kernel_size, stride=None, ceil_mode=False):\n\n    data_format = \"NCHW\"\n    padding = \"VALID\"\n    if stride is not None:\n        out = ivy.avg_pool2d(\n            ivy.pow(input, norm_type),\n            kernel_size,\n            stride,\n            padding,\n            data_format=data_format,\n        )\n    else:\n        out = ivy.avg_pool2d(\n            ivy.pow(input, norm_type),\n            kernel_size,\n            kernel_size,\n            padding,\n            data_format=data_format,\n        )\n    if not isinstance(kernel_size, int):\n        kernel_size = kernel_size[0] * kernel_size[1]\n    return ivy.pow(ivy.multiply(out, kernel_size), ivy.divide(1.0, norm_type))\n", "path": "ivy/functional/frontends/torch/nn/functional/pooling_functions.py"}]}