internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: ivy-llc/ivy

Issue:
count_nonzero



Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/paddle/math.py b/ivy/functional/frontends/paddle/math.py
--- a/ivy/functional/frontends/paddle/math.py
+++ b/ivy/functional/frontends/paddle/math.py
@@ -134,6 +134,15 @@ def cosh(x, name=None):
     return ivy.cosh(x)
 
 
+@with_supported_dtypes(
+    {"2.5.1 and below": ("int32", "int64", "float16", "float32", "float64", "bool")},
+    "paddle",
+)
+@to_ivy_arrays_and_back
+def count_nonzero(x, axis=None, keepdim=False, name=None):
+    return ivy.astype(ivy.count_nonzero(x, axis=axis, keepdims=keepdim), ivy.int64)
+
+
 @with_supported_dtypes(
     {
         "2.5.1 and below": (


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_math.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_math.py
--- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_math.py
+++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_math.py
@@ -586,6 +586,38 @@ def test_paddle_cosh(
     )
 
 
+# count_nonzero
+@handle_frontend_test(
+    fn_tree="paddle.count_nonzero",
+    dtype_and_x=helpers.dtype_values_axis(
+        available_dtypes=helpers.get_dtypes(kind="integer"),
+        valid_axis=True,
+        force_int_axis=True,
+        min_num_dims=1,
+    ),
+)
+def test_paddle_count_nonzero(
+    *,
+    dtype_and_x,
+    on_device,
+    fn_tree,
+    frontend,
+    backend_fw,
+    test_flags,
+):
+    input_dtype, x, axis = dtype_and_x
+    helpers.test_frontend_function(
+        input_dtypes=input_dtype,
+        backend_to_test=backend_fw,
+        on_device=on_device,
+        fn_tree=fn_tree,
+        test_flags=test_flags,
+        frontend=frontend,
+        x=x[0],
+        axis=axis,
+    )
+
+
 # cumprod
 @handle_frontend_test(
     fn_tree="paddle.cumprod",
Repository: ivy-llc/ivy

Issue:
rfftfreq



Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/paddle/fft.py b/ivy/functional/frontends/paddle/fft.py
--- a/ivy/functional/frontends/paddle/fft.py
+++ b/ivy/functional/frontends/paddle/fft.py
@@ -122,3 +122,12 @@ def irfft(x, n=None, axis=-1.0, norm="backward", name=None):
     if ivy.isreal(x):
         time_domain = ivy.real(time_domain)
     return time_domain
+
+
+@to_ivy_arrays_and_back
+def rfftfreq(n, d=1.0, dtype=None, name=None):
+    dtype = ivy.default_dtype()
+    val = 1.0 / (n * d)
+    pos_max = n // 2 + 1
+    indices = ivy.arange(0, pos_max, dtype=dtype)
+    return indices * val


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_fft.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_fft.py
--- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_fft.py
+++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_fft.py
@@ -220,3 +220,25 @@ def test_paddle_irfft(
         valid_axis=True,
         force_int_axis=True,
     )
+
+
+@handle_frontend_test(
+    fn_tree="paddle.fft.rfftfreq",
+    n=st.integers(min_value=1, max_value=1000),
+    sample_rate=st.integers(min_value=1, max_value=20),
+)
+def test_paddle_rfftfreq(
+    n, sample_rate, backend_fw, frontend, test_flags, fn_tree, on_device
+):
+    d = 1 / sample_rate
+    helpers.test_frontend_function(
+        input_dtypes=[int],
+        frontend=frontend,
+        backend_to_test=backend_fw,
+        test_flags=test_flags,
+        fn_tree=fn_tree,
+        on_device=on_device,
+        test_values=True,
+        n=n,
+        d=d,
+    )
Repository: ivy-llc/ivy

Issue:
empty_strided



Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/torch/creation_ops.py b/ivy/functional/frontends/torch/creation_ops.py
--- a/ivy/functional/frontends/torch/creation_ops.py
+++ b/ivy/functional/frontends/torch/creation_ops.py
@@ -93,6 +93,24 @@ def empty_like(
     return ret
 
 
+@to_ivy_arrays_and_back
+def empty_strided(
+    size,
+    stride,
+    *,
+    dtype=None,
+    layout=None,
+    device=None,
+    requires_grad=False,
+    pin_memory=False,
+):
+    max_offsets = [(s - 1) * st for s, st in zip(size, stride)]
+    items = sum(max_offsets) + 1
+    empty_array = empty(items, dtype=dtype, device=device)
+    strided_array = as_strided(empty_array, size, stride)
+    return strided_array
+
+
 @to_ivy_arrays_and_back
 def eye(
     n, m=None, *, out=None, dtype=None, layout=None, device=None, requires_grad=False


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_torch/test_creation_ops.py b/ivy_tests/test_ivy/test_frontends/test_torch/test_creation_ops.py
--- a/ivy_tests/test_ivy/test_frontends/test_torch/test_creation_ops.py
+++ b/ivy_tests/test_ivy/test_frontends/test_torch/test_creation_ops.py
@@ -323,6 +323,33 @@ def test_torch_empty_like(
     )
 
 
+@handle_frontend_test(
+    fn_tree="torch.empty_strided",
+    dtype_x_and_other=_as_strided_helper(),
+)
+def test_torch_empty_strided(
+    *,
+    dtype_x_and_other,
+    on_device,
+    fn_tree,
+    frontend,
+    test_flags,
+    backend_fw,
+):
+    x_dtype, x, size, stride, offset = dtype_x_and_other
+    helpers.test_frontend_function(
+        input_dtypes=x_dtype,
+        backend_to_test=backend_fw,
+        frontend=frontend,
+        test_flags=test_flags,
+        fn_tree=fn_tree,
+        on_device=on_device,
+        size=size,
+        stride=stride,
+        test_values=False,
+    )
+
+
 # from_dlpack
 @handle_frontend_test(
     fn_tree="torch.from_dlpack",
Repository: ivy-llc/ivy

Issue:
[Bug]: maxwell
### Bug Explanation

I recently learnt that, to verify if the random function is working alright one needs to also plot the histogram graph of the particular function along side the histogram graph of a back-end function for a large number of outputs to verify if they look similar.

I had pushed a Maxwell function that passed all the tests. but when I plotted the histogram graph as explained above they looked very different. The graph is as shown bellow,  

![image](https://github.com/unifyai/ivy/assets/64426988/0e211cfb-e180-4f65-9502-a9278e76f84d)


The code for the same is mentioned in the next section.

### Steps to Reproduce Bug

`%matplotlib inline
```
import matplotlib
import ivy
import jax
from ivy.functional.frontends.jax.random import _get_seed
```

# current function in Ivy repository
```
def maxwell_current(key, shape=None, dtype="float64"):
    seed = _get_seed(key)
    # generate uniform random numbers between 0 and 1
    z = ivy.random_uniform(seed=seed, shape=shape, dtype=dtype)
    # applying inverse transform sampling
    x = (z**2) * ivy.exp(-(z**2) / 2)
    return x
```


# edited version
```
def maxwell(key, shape, dtype= "float64"):
    seed = _get_seed(key)
    shape = shape + (3,)
    random_normal = ivy.random_normal(seed=seed, shape=shape, dtype=dtype)
    return ivy.vector_norm(random_normal, axis=-1)

```


```
n = 1000000
import matplotlib.pyplot as plt
x = maxwell_current((123,123), (n,))
y = maxwell((123,123), (n,))
z = jax.random.maxwell(jax.numpy.array([123,123], dtype='uint32'), shape=(n,))

num_bins = int(ivy.sqrt(n))
n0, bins0, patches0 = plt.hist(x, bins=num_bins, histtype='step', color='blue')
n, bins, patches = plt.hist(y, bins=num_bins, histtype='step', color='black')
n, bins, patches = plt.hist(z, bins=num_bins, histtype='step', color='red')

plt.plot()
````

### Environment

In general, in colab.

### Ivy Version

v1.1.9

### Backend

- [ ] NumPy
- [ ] TensorFlow
- [ ] PyTorch
- [X] JAX

### Device

_No response_


Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/jax/random.py b/ivy/functional/frontends/jax/random.py
--- a/ivy/functional/frontends/jax/random.py
+++ b/ivy/functional/frontends/jax/random.py
@@ -270,13 +270,11 @@ def logistic(key, shape=(), dtype="float64"):
     },
     "jax",
 )
-def maxwell(key, shape=None, dtype="float64"):
+def maxwell(key, shape, dtype="float64"):
     seed = _get_seed(key)
-    # generate uniform random numbers between 0 and 1
-    z = ivy.random_uniform(seed=seed, shape=shape, dtype=dtype)
-    # applying inverse transform sampling
-    x = (z**2) * ivy.exp(-(z**2) / 2)
-    return x
+    shape = shape + (3,)
+    random_normal = ivy.random_normal(seed=seed, shape=shape, dtype=dtype)
+    return ivy.vector_norm(random_normal, axis=-1)
 
 
 @handle_jax_dtype


Test patch:
Repository: ivy-llc/ivy

Issue:
noncentral_chisquare



Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/numpy/random/functions.py b/ivy/functional/frontends/numpy/random/functions.py
--- a/ivy/functional/frontends/numpy/random/functions.py
+++ b/ivy/functional/frontends/numpy/random/functions.py
@@ -5,6 +5,7 @@
     to_ivy_arrays_and_back,
     from_zero_dim_arrays_to_scalar,
 )
+from ivy import with_supported_dtypes
 
 
 @to_ivy_arrays_and_back
@@ -174,6 +175,27 @@ def negative_binomial(n, p, size=None):
     return ivy.poisson(lam=lambda_, shape=size)
 
 
+@with_supported_dtypes(
+    {"1.25.2 and below": ("float16", "float32")},
+    "numpy",
+)
+@to_ivy_arrays_and_back
+@from_zero_dim_arrays_to_scalar
+def noncentral_chisquare(df, nonc, size=None):
+    if ivy.any(df <= 0):
+        raise ValueError("Degree of freedom must be greater than 0")
+    if ivy.has_nans(nonc):
+        return ivy.nan
+    if ivy.any(nonc == 0):
+        return chisquare(df, size=size)
+    if ivy.any(df < 1):
+        n = standard_normal() + ivy.sqrt(nonc)
+        return chisquare(df - 1, size=size) + n * n
+    else:
+        i = poisson(nonc / 2.0, size=size)
+        return chisquare(df + 2 * i, size=size)
+
+
 @to_ivy_arrays_and_back
 @from_zero_dim_arrays_to_scalar
 def normal(loc=0.0, scale=1.0, size=None):


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_numpy/test_random/test_functions.py b/ivy_tests/test_ivy/test_frontends/test_numpy/test_random/test_functions.py
--- a/ivy_tests/test_ivy/test_frontends/test_numpy/test_random/test_functions.py
+++ b/ivy_tests/test_ivy/test_frontends/test_numpy/test_random/test_functions.py
@@ -637,6 +637,47 @@ def test_numpy_negative_binomial(
     )
 
 
+# noncentral_chisquare
+@handle_frontend_test(
+    fn_tree="numpy.random.noncentral_chisquare",
+    dtype_and_df=helpers.dtype_and_values(
+        available_dtypes=helpers.get_dtypes("valid"),
+        min_value=0,
+        exclude_min=True,
+    ),
+    dtype_and_nonc=helpers.dtype_and_values(
+        available_dtypes=helpers.get_dtypes("valid"),
+        min_value=0,
+    ),
+    size=helpers.get_shape(allow_none=True),
+    test_with_out=st.just(False),
+)
+def test_numpy_noncentral_chisquare(
+    dtype_and_df,
+    dtype_and_nonc,
+    size,
+    frontend,
+    test_flags,
+    fn_tree,
+    backend_fw,
+    on_device,
+):
+    dtype_df, df = dtype_and_df
+    dtype_nonc, nonc = dtype_and_nonc
+    helpers.test_frontend_function(
+        input_dtypes=dtype_df + dtype_nonc,
+        backend_to_test=backend_fw,
+        frontend=frontend,
+        test_flags=test_flags,
+        fn_tree=fn_tree,
+        on_device=on_device,
+        test_values=False,
+        df=df[0],
+        nonc=nonc[0],
+        size=size,
+    )
+
+
 # normal
 @handle_frontend_test(
     fn_tree="numpy.random.normal",
Repository: ivy-llc/ivy

Issue:
Fix stat.test_paddle_mean
|   |   |
|---|---|
|numpy|<a href="https://github.com/unifyai/ivy/actions/runs/6217246144/job/16872089804"><img src=https://img.shields.io/badge/-failure-red></a>
|jax|<a href="https://github.com/unifyai/ivy/actions/runs/6217246144/job/16872089804"><img src=https://img.shields.io/badge/-failure-red></a>
|tensorflow|<a href="https://github.com/unifyai/ivy/actions/runs/6217246144/job/16872089804"><img src=https://img.shields.io/badge/-failure-red></a>
|torch|<a href="https://github.com/unifyai/ivy/actions/runs/6220534211"><img src=https://img.shields.io/badge/-failure-red></a>
|paddle|<a href="https://github.com/unifyai/ivy/actions/runs/6217246144/job/16872089804"><img src=https://img.shields.io/badge/-failure-red></a>



Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/paddle/stat.py b/ivy/functional/frontends/paddle/stat.py
--- a/ivy/functional/frontends/paddle/stat.py
+++ b/ivy/functional/frontends/paddle/stat.py
@@ -10,7 +10,6 @@
 @to_ivy_arrays_and_back
 def mean(input, axis=None, keepdim=False, out=None):
     ret = ivy.mean(input, axis=axis, keepdims=keepdim, out=out)
-    ret = ivy.expand_dims(ret, axis=-1) if ret.ndim == 0 else ret
     return ret
 
 


Test patch:
Repository: ivy-llc/ivy

Issue:
digamma



Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/paddle/tensor/tensor.py b/ivy/functional/frontends/paddle/tensor/tensor.py
--- a/ivy/functional/frontends/paddle/tensor/tensor.py
+++ b/ivy/functional/frontends/paddle/tensor/tensor.py
@@ -596,6 +596,13 @@ def max(self, axis=None, keepdim=False, name=None):
     def deg2rad(self, name=None):
         return paddle_frontend.Tensor(ivy.deg2rad(self._ivy_array))
 
+    @with_supported_dtypes({"2.5.1 and below": ("float32", "float64")}, "paddle")
+    def digamma(self, name=None):
+        digamma_fun = ivy.digamma
+        return paddle_frontend.Tensor(
+            ivy.astype(digamma_fun(self._ivy_array), self.dtype)
+        )
+
     @with_supported_dtypes(
         {"2.5.1 and below": ("float32", "float64", "int32", "int64", "bool")}, "paddle"
     )


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_tensor.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_tensor.py
--- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_tensor.py
+++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_tensor.py
@@ -1468,6 +1468,43 @@ def test_paddle_tensor_device(
     )
 
 
+# digamma
+@handle_frontend_method(
+    class_tree=CLASS_TREE,
+    init_tree="paddle.to_tensor",
+    method_name="digamma",
+    dtype_and_x=helpers.dtype_and_values(
+        available_dtypes=helpers.get_dtypes("float"),
+        min_value=1,
+        max_value=1e5,
+    ),
+)
+def test_paddle_tensor_digamma(
+    dtype_and_x,
+    frontend_method_data,
+    init_flags,
+    method_flags,
+    frontend,
+    on_device,
+    backend_fw,
+):
+    input_dtype, x = dtype_and_x
+    helpers.test_frontend_method(
+        init_input_dtypes=input_dtype,
+        backend_to_test=backend_fw,
+        init_all_as_kwargs_np={
+            "data": x[0],
+        },
+        method_input_dtypes=input_dtype,
+        method_all_as_kwargs_np={},
+        frontend_method_data=frontend_method_data,
+        init_flags=init_flags,
+        method_flags=method_flags,
+        frontend=frontend,
+        on_device=on_device,
+    )
+
+
 # dim
 @handle_frontend_method(
     class_tree=CLASS_TREE,
Repository: ivy-llc/ivy

Issue:
unbind



Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/paddle/manipulation.py b/ivy/functional/frontends/paddle/manipulation.py
--- a/ivy/functional/frontends/paddle/manipulation.py
+++ b/ivy/functional/frontends/paddle/manipulation.py
@@ -171,6 +171,18 @@ def tile(x, repeat_times, name=None):
     return ivy.tile(x, repeats=repeat_times)
 
 
+@with_supported_dtypes(
+    {"2.5.1 and below": ("bool", "int32", "int64", "float16", "float32", "float64")},
+    "paddle",
+)
+@to_ivy_arrays_and_back
+def unbind(input, axis=0):
+    shape = list(input.shape)
+    num_splits = shape[axis]
+    shape.pop(axis)
+    return tuple([x.reshape(tuple(shape)) for x in split(input, num_splits, axis=axis)])
+
+
 @with_supported_dtypes(
     {
         "2.5.1 and below": (


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_manipulation.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_manipulation.py
--- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_manipulation.py
+++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_manipulation.py
@@ -721,6 +721,43 @@ def test_paddle_tile(
     )
 
 
+# unbind
+@handle_frontend_test(
+    fn_tree="paddle.unbind",
+    dtypes_values=helpers.dtype_and_values(
+        available_dtypes=helpers.get_dtypes("valid"),
+        min_num_dims=2,
+        max_num_dims=2,
+        max_dim_size=1,
+    ),
+    number_positional_args=st.just(1),
+    axis=st.integers(-1, 0),
+    test_with_out=st.just(False),
+)
+def test_paddle_unbind(
+    *,
+    dtypes_values,
+    axis,
+    on_device,
+    fn_tree,
+    backend_fw,
+    frontend,
+    test_flags,
+):
+    x_dtype, x = dtypes_values
+    axis = axis
+    helpers.test_frontend_function(
+        input_dtypes=x_dtype,
+        backend_to_test=backend_fw,
+        frontend=frontend,
+        test_flags=test_flags,
+        fn_tree=fn_tree,
+        on_device=on_device,
+        x=x[0],
+        axis=axis,
+    )
+
+
 # unstack
 @handle_frontend_test(
     fn_tree="paddle.unstack",
Repository: ivy-llc/ivy

Issue:
[Bug]: paddle backend vstack
### Bug Explanation

The paddle backend implementation of function vstack can't process combination of 1D and 2D arrays.

### Steps to Reproduce Bug

```
ivy.set_backend('paddle')
a1 = ivy.array([1])
a2 = ivy.array([[2]])
ivy.experimental.vstack((a1, a2))
```
does not work, as opposed to
```
ivy.set_backend('torch')
a1 = ivy.array([1])
a2 = ivy.array([[2]])
ivy.experimental.vstack((a1, a2))
```

### Environment

VSCode Codespaces

### Ivy Version

Dev repo

### Backend

- [ ] NumPy
- [ ] TensorFlow
- [ ] PyTorch
- [ ] JAX

### Device

_No response_


Discussion:

Resolving patch:
diff --git a/ivy/functional/backends/paddle/experimental/manipulation.py b/ivy/functional/backends/paddle/experimental/manipulation.py
--- a/ivy/functional/backends/paddle/experimental/manipulation.py
+++ b/ivy/functional/backends/paddle/experimental/manipulation.py
@@ -198,10 +198,6 @@ def flipud(
     return paddle.flip(m, axis=0)
 
 
-@with_unsupported_device_and_dtypes(
-    {"2.5.1 and below": {"cpu": ("int16", "float16")}},
-    backend_version,
-)
 def vstack(
     arrays: Sequence[paddle.Tensor],
     /,
@@ -209,10 +205,8 @@ def vstack(
     out: Optional[paddle.Tensor] = None,
 ) -> paddle.Tensor:
     with ivy.ArrayMode(False):
-        if arrays[0].ndim >= 2:
-            return ivy.concat(arrays, axis=0)
-        else:
-            return ivy.stack(arrays, axis=0)
+        arrays = [ivy.reshape(x, shape=(1, -1)) if x.ndim < 2 else x for x in arrays]
+        return ivy.concat(arrays, axis=0)
 
 
 @with_unsupported_device_and_dtypes(


Test patch:
diff --git a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_manipulation.py b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_manipulation.py
--- a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_manipulation.py
+++ b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_manipulation.py
@@ -1408,23 +1408,16 @@ def test_vsplit(
 # vstack
 @handle_test(
     fn_tree="functional.ivy.experimental.vstack",
-    dtype_and_m=helpers.dtype_and_values(
-        available_dtypes=helpers.get_dtypes("valid"),
-        shape=helpers.get_shape(
-            min_num_dims=1,
-        ),
-        shared_dtype=True,
-        num_arrays=helpers.ints(min_value=2, max_value=10),
-    ),
+    arrays_dtypes=_st_col_row_stack_arrays(stack_dim=0),
     test_gradients=st.just(False),
 )
-def test_vstack(*, dtype_and_m, test_flags, backend_fw, fn_name, on_device):
-    input_dtype, m = dtype_and_m
+def test_vstack(*, arrays_dtypes, test_flags, backend_fw, fn_name, on_device):
+    arrays, dtypes = arrays_dtypes
     helpers.test_function(
-        input_dtypes=input_dtype,
+        input_dtypes=dtypes,
         test_flags=test_flags,
         on_device=on_device,
         backend_to_test=backend_fw,
         fn_name=fn_name,
-        arrays=m,
+        arrays=arrays,
     )
Repository: ivy-llc/ivy

Issue:
avg_pool2d



Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/tensorflow/nn.py b/ivy/functional/frontends/tensorflow/nn.py
--- a/ivy/functional/frontends/tensorflow/nn.py
+++ b/ivy/functional/frontends/tensorflow/nn.py
@@ -88,6 +88,12 @@ def avg_pool1d(input, ksize, strides, padding, data_format="NWC", name=None):
     return ivy.avg_pool1d(input, ksize, strides, padding, data_format=data_format)
 
 
+# avg_pool2d
+@to_ivy_arrays_and_back
+def avg_pool2d(input, ksize, strides, padding, data_format="NHWC", name=None):
+    return ivy.avg_pool2d(input, ksize, strides, padding, data_format=data_format)
+
+
 # avg_pool3d
 @to_ivy_arrays_and_back
 def avg_pool3d(input, ksize, strides, padding, data_format="NDHWC", name=None):


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_nn.py b/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_nn.py
--- a/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_nn.py
+++ b/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_nn.py
@@ -676,6 +676,37 @@ def test_tensorflow_avg_pool1d(
     )
 
 
+@handle_frontend_test(
+    fn_tree="tensorflow.nn.avg_pool2d",
+    x_k_s_p_df=helpers.arrays_for_pooling(
+        min_dims=4, max_dims=4, min_side=1, max_side=4
+    ),
+    test_with_out=st.just(False),
+)
+def test_tensorflow_avg_pool2d(
+    *,
+    x_k_s_p_df,
+    frontend,
+    test_flags,
+    fn_tree,
+    backend_fw,
+    on_device,
+):
+    input_dtype, x, ksize, strides, padding = x_k_s_p_df
+    helpers.test_frontend_function(
+        input_dtypes=input_dtype,
+        backend_to_test=backend_fw,
+        frontend=frontend,
+        test_flags=test_flags,
+        fn_tree=fn_tree,
+        on_device=on_device,
+        input=x[0],
+        ksize=ksize,
+        strides=strides,
+        padding=padding,
+    )
+
+
 @handle_frontend_test(
     fn_tree="tensorflow.nn.avg_pool3d",
     x_k_s_p_df=helpers.arrays_for_pooling(
Repository: ivy-llc/ivy

Issue:
nansum



Discussion:

Resolving patch:
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
@@ -191,6 +191,16 @@ def nanmean(input, dim=None, keepdim=False, *, dtype=None, out=None):
     return ivy.nanmean(input, axis=dim, keepdims=keepdim, dtype=dtype, out=out)
 
 
+@to_ivy_arrays_and_back
+@with_supported_dtypes(
+    {"2.0.1 and below": ("float", "int")},
+    "torch",
+)
+def nansum(input, dim=None, keepdim=False, *, dtype=None):
+    input = ivy.where(ivy.isnan(input), ivy.zeros_like(input), input)
+    return ivy.sum(input, axis=dim, dtype=dtype, keepdims=keepdim, out=None)
+
+
 @to_ivy_arrays_and_back
 @with_supported_dtypes(
     {"2.0.1 and below": ("float", "complex")},


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_torch/test_reduction_ops.py b/ivy_tests/test_ivy/test_frontends/test_torch/test_reduction_ops.py
--- a/ivy_tests/test_ivy/test_frontends/test_torch/test_reduction_ops.py
+++ b/ivy_tests/test_ivy/test_frontends/test_torch/test_reduction_ops.py
@@ -672,6 +672,42 @@ def test_torch_nanmean(
     )
 
 
+@handle_frontend_test(
+    fn_tree="torch.nansum",
+    dtype_and_x=_get_castable_dtype(
+        min_value=-1e04,
+        max_value=1e04,
+    ),
+    keepdims=st.booleans(),
+)
+def test_torch_nansum(
+    *,
+    dtype_and_x,
+    keepdims,
+    on_device,
+    fn_tree,
+    frontend,
+    test_flags,
+    backend_fw,
+):
+    input_dtype, x, axis, castable_dtype = dtype_and_x
+    if test_flags.as_variable:
+        castable_dtype = input_dtype
+    input_dtype = [input_dtype]
+    helpers.test_frontend_function(
+        input_dtypes=input_dtype,
+        backend_to_test=backend_fw,
+        frontend=frontend,
+        test_flags=test_flags,
+        fn_tree=fn_tree,
+        on_device=on_device,
+        input=x[0],
+        dim=axis,
+        keepdim=keepdims,
+        dtype=castable_dtype,
+    )
+
+
 # norm
 @handle_frontend_test(
     fn_tree="torch.norm",