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

Issue:
randint



Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/torch/random_sampling.py b/ivy/functional/frontends/torch/random_sampling.py
--- a/ivy/functional/frontends/torch/random_sampling.py
+++ b/ivy/functional/frontends/torch/random_sampling.py
@@ -56,6 +56,29 @@ def poisson(input, generator=None):
     return ivy.poisson(input, shape=None)
 
 
+@to_ivy_arrays_and_back
+def randint(
+    low,
+    high,
+    size,
+    *,
+    generator=None,
+    out=None,
+    dtype=None,
+    layout=None,
+    device=None,
+    requires_grad=False
+):
+    return ivy.randint(
+        low,
+        high,
+        shape=size,
+        out=out,
+        dtype=dtype,
+        device=device,
+    )
+
+
 @to_ivy_arrays_and_back
 def rand(
     size,


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_torch/test_random_sampling.py b/ivy_tests/test_ivy/test_frontends/test_torch/test_random_sampling.py
--- a/ivy_tests/test_ivy/test_frontends/test_torch/test_random_sampling.py
+++ b/ivy_tests/test_ivy/test_frontends/test_torch/test_random_sampling.py
@@ -130,6 +130,49 @@ def call():
         assert u.shape == v.shape
 
 
+# randint
+@handle_frontend_test(
+    fn_tree="torch.randint",
+    low=helpers.ints(min_value=0, max_value=10),
+    high=helpers.ints(min_value=11, max_value=20),
+    size=helpers.get_shape(),
+    dtype=helpers.get_dtypes("integer"),
+)
+def test_torch_randint(
+    *,
+    low,
+    high,
+    size,
+    dtype,
+    frontend,
+    test_flags,
+    fn_tree,
+):
+    def call():
+        helpers.test_frontend_function(
+            input_dtypes=dtype,
+            frontend=frontend,
+            test_values=False,
+            fn_tree=fn_tree,
+            test_flags=test_flags,
+            low=low,
+            high=high,
+            size=size,
+        )
+
+    ret = call()
+
+    if not ivy.exists(ret):
+        return
+
+    ret_np, ret_from_np = ret
+    ret_np = helpers.flatten_and_to_np(ret=ret_np)
+    ret_from_np = helpers.flatten_and_to_np(ret=ret_from_np)
+    for (u, v) in zip(ret_np, ret_from_np):
+        assert u.dtype == v.dtype
+        assert u.shape == v.shape
+
+
 @handle_frontend_test(
     fn_tree="torch.rand",
     dtype=helpers.get_dtypes("float", full=False),
Repository: ivy-llc/ivy

Issue:
Reverse



Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/tensorflow/raw_ops.py b/ivy/functional/frontends/tensorflow/raw_ops.py
--- a/ivy/functional/frontends/tensorflow/raw_ops.py
+++ b/ivy/functional/frontends/tensorflow/raw_ops.py
@@ -239,6 +239,15 @@ def Reciprocal(*, x, name=None):
     return ivy.reciprocal(x)
 
 
+@to_ivy_arrays_and_back
+def Reverse(*, tensor, dims, name="Reverse"):
+    ret = tensor
+    for dim in enumerate(dims):
+        if dim[1]:
+            ret = ivy.flip(ret, axis=dim[0])
+    return ret
+
+
 @to_ivy_arrays_and_back
 def Invert(*, x, name="Invert"):
     return ivy.bitwise_invert(x)


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_raw_ops.py b/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_raw_ops.py
--- a/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_raw_ops.py
+++ b/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_raw_ops.py
@@ -1526,6 +1526,54 @@ def test_tensorflow_Reshape(  # NOQA
     )
 
 
+# Reverse
+@st.composite
+def reverse_helper(draw):
+    dtype, x, shape = draw(
+        helpers.dtype_and_values(
+            available_dtypes=helpers.get_dtypes("numeric"),
+            min_num_dims=1,
+            max_num_dims=8,
+            ret_shape=True,
+        )
+    )
+    axis_dtype, axis = draw(
+        helpers.dtype_and_values(
+            available_dtypes=["bool"],
+            min_num_dims=1,
+            max_num_dims=1,
+            num_arrays=1,
+            shape=(len(shape),),
+        )
+    )
+    return dtype, x, axis_dtype, axis
+
+
+@handle_frontend_test(
+    fn_tree="tensorflow.raw_ops.Reverse",
+    dtype_x_axis=reverse_helper(),
+)
+def test_tensorflow_Reverse(
+    *,
+    dtype_x_axis,
+    frontend,
+    fn_tree,
+    test_flags,
+    on_device,
+):
+
+    dtype, x, axis_dtype, axis = dtype_x_axis
+    helpers.test_frontend_function(
+        input_dtypes=dtype + axis_dtype,
+        test_flags=test_flags,
+        frontend=frontend,
+        fn_tree=fn_tree,
+        on_device=on_device,
+        tensor=x[0],
+        dims=axis[0],
+    )
+
+
 # ZerosLike
 @handle_frontend_test(
     fn_tree="tensorflow.raw_ops.ZerosLike",
Repository: ivy-llc/ivy

Issue:
_get_devices
Rewrite using type hints for arguments and return type


Discussion:

Resolving patch:
diff --git a/ivy/functional/ivy/device.py b/ivy/functional/ivy/device.py
--- a/ivy/functional/ivy/device.py
+++ b/ivy/functional/ivy/device.py
@@ -1094,7 +1094,7 @@ def _is_valid_devices_attributes(fn: Callable) -> bool:
     return True
 
 
-def _get_devices(fn, complement=True):
+def _get_devices(fn: Callable, complement: bool = True) -> Tuple:
     valid_devices = ivy.valid_devices
     invalid_devices = ivy.invalid_devices
     all_devices = ivy.all_devices


Test patch:
Repository: ivy-llc/ivy

Issue:
frexp



Discussion:

Resolving patch:
diff --git a/ivy/functional/backends/torch/experimental/elementwise.py b/ivy/functional/backends/torch/experimental/elementwise.py
--- a/ivy/functional/backends/torch/experimental/elementwise.py
+++ b/ivy/functional/backends/torch/experimental/elementwise.py
@@ -513,4 +513,5 @@ def frexp(
     *,
     out: Optional[Tuple[torch.Tensor, torch.Tensor]] = None,
 ) -> Tuple[torch.Tensor, torch.Tensor]:
-    return torch.frexp(x, out=out)
+    mantissa, exponent = torch.frexp(x, out=out)
+    return mantissa, exponent
diff --git a/ivy/functional/frontends/torch/pointwise_ops.py b/ivy/functional/frontends/torch/pointwise_ops.py
--- a/ivy/functional/frontends/torch/pointwise_ops.py
+++ b/ivy/functional/frontends/torch/pointwise_ops.py
@@ -505,6 +505,12 @@ def logit(input, eps=None, *, out=None):
     return ivy.log(ivy.divide(input, ivy.subtract(1, input), out=out), out=out)
 
 
+@with_unsupported_dtypes({"1.11.0 and below": ("float16", "bfloat16")}, "torch")
+@to_ivy_arrays_and_back
+def frexp(input, *, out=None):
+    return ivy.frexp(input, out=out)
+
+
 @with_unsupported_dtypes({"1.11.0 and below": ("float16", "complex")}, "torch")
 @to_ivy_arrays_and_back
 def erf(input, *, out=None):


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_torch/test_pointwise_ops.py b/ivy_tests/test_ivy/test_frontends/test_torch/test_pointwise_ops.py
--- a/ivy_tests/test_ivy/test_frontends/test_torch/test_pointwise_ops.py
+++ b/ivy_tests/test_ivy/test_frontends/test_torch/test_pointwise_ops.py
@@ -2423,6 +2423,37 @@ def test_torch_erf(
     )
 
 
+@handle_frontend_test(
+    fn_tree="torch.frexp",
+    dtype_and_x=helpers.dtype_and_values(
+        available_dtypes=helpers.get_dtypes("float"),
+        num_arrays=1,
+        shared_dtype=True,
+        min_value=-10,
+        max_value=10,
+        min_num_dims=1,
+        max_num_dims=1,
+    ),
+)
+def test_torch_frexp(
+    dtype_and_x,
+    on_device,
+    fn_tree,
+    frontend,
+    test_flags,
+):
+    input_dtype, input = dtype_and_x
+    helpers.test_frontend_function(
+        input_dtypes=input_dtype,
+        frontend=frontend,
+        test_flags=test_flags,
+        fn_tree=fn_tree,
+        on_device=on_device,
+        input=input[0],
+        out=None,
+    )
+
+
 @handle_frontend_test(
     fn_tree="torch.sgn",
     dtype_and_input=helpers.dtype_and_values(
Repository: ivy-llc/ivy

Issue:
__complex__



Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/numpy/ndarray/ndarray.py b/ivy/functional/frontends/numpy/ndarray/ndarray.py
--- a/ivy/functional/frontends/numpy/ndarray/ndarray.py
+++ b/ivy/functional/frontends/numpy/ndarray/ndarray.py
@@ -409,12 +409,17 @@ def __lt__(self, value, /):
     def __int__(
         self,
     ):
-        return ivy.array(ivy.reshape(self.ivy_array, -1), dtype=ivy.int64)[0]
+        return ivy.array(ivy.reshape(self.ivy_array, (-1,)), dtype=ivy.int64)[0]
 
     def __float__(
         self,
     ):
-        return ivy.array(ivy.reshape(self.ivy_array, -1), dtype=ivy.float64)[0]
+        return ivy.array(ivy.reshape(self.ivy_array, (-1,)), dtype=ivy.float64)[0]
+
+    def __complex__(
+        self,
+    ):
+        return ivy.array(ivy.reshape(self.ivy_array, (-1,)), dtype=ivy.complex128)[0]
 
     def __contains__(self, key, /):
         return key in ivy.reshape(self.ivy_array, -1)


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_numpy/test_ndarray/test_ndarray.py b/ivy_tests/test_ivy/test_frontends/test_numpy/test_ndarray/test_ndarray.py
--- a/ivy_tests/test_ivy/test_frontends/test_numpy/test_ndarray/test_ndarray.py
+++ b/ivy_tests/test_ivy/test_frontends/test_numpy/test_ndarray/test_ndarray.py
@@ -2159,6 +2159,41 @@ def test_numpy_instance_float__(
     )
 
 
+@handle_frontend_method(
+    class_tree=CLASS_TREE,
+    init_tree="numpy.array",
+    method_name="__complex__",
+    dtype_and_x=helpers.dtype_and_values(
+        available_dtypes=helpers.get_dtypes("numeric"),
+        min_dim_size=1,
+        max_dim_size=1,
+    ),
+)
+def test_numpy_instance_complex__(
+    dtype_and_x,
+    frontend_method_data,
+    init_flags,
+    method_flags,
+    frontend,
+    on_device,
+):
+    input_dtypes, xs = dtype_and_x
+
+    helpers.test_frontend_method(
+        init_input_dtypes=input_dtypes,
+        method_input_dtypes=input_dtypes,
+        init_all_as_kwargs_np={
+            "object": xs[0],
+        },
+        method_all_as_kwargs_np={},
+        frontend=frontend,
+        frontend_method_data=frontend_method_data,
+        init_flags=init_flags,
+        method_flags=method_flags,
+        on_device=on_device,
+    )
+
+
 @handle_frontend_method(
     class_tree=CLASS_TREE,
     init_tree="numpy.array",
Repository: ivy-llc/ivy

Issue:
arcsinh



Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/torch/tensor.py b/ivy/functional/frontends/torch/tensor.py
--- a/ivy/functional/frontends/torch/tensor.py
+++ b/ivy/functional/frontends/torch/tensor.py
@@ -142,6 +142,10 @@ def cosh_(self):
         self._ivy_array = self.cosh().ivy_array
         return self
 
+    @with_unsupported_dtypes({"1.11.0 and below": ("float16",)}, "torch")
+    def arcsinh(self):
+        return torch_frontend.arcsinh(self._ivy_array)
+
     @with_unsupported_dtypes({"1.11.0 and below": ("float16",)}, "torch")
     def arcsin(self):
         return torch_frontend.arcsin(self._ivy_array)


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py b/ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py
--- a/ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py
+++ b/ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py
@@ -1506,6 +1506,41 @@ def test_torch_special_add(
     )
 
 
+# arcsinh
+@handle_frontend_method(
+    class_tree=CLASS_TREE,
+    init_tree="torch.tensor",
+    method_name="arcsinh",
+    dtype_and_x=helpers.dtype_and_values(
+        min_value=-1.0,
+        max_value=1.0,
+        available_dtypes=helpers.get_dtypes("float"),
+    ),
+)
+def test_torch_instance_arcsinh(
+    dtype_and_x,
+    frontend_method_data,
+    init_flags,
+    method_flags,
+    frontend,
+    on_device,
+):
+    input_dtype, x = dtype_and_x
+    helpers.test_frontend_method(
+        init_input_dtypes=input_dtype,
+        init_all_as_kwargs_np={
+            "data": x[0],
+        },
+        method_input_dtypes=[],
+        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,
+    )
+
+
 # __long__
 @handle_frontend_method(
     class_tree=CLASS_TREE,
Repository: ivy-llc/ivy

Issue:
randperm



Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/torch/random_sampling.py b/ivy/functional/frontends/torch/random_sampling.py
--- a/ivy/functional/frontends/torch/random_sampling.py
+++ b/ivy/functional/frontends/torch/random_sampling.py
@@ -129,3 +129,21 @@ def randn(
 @to_ivy_arrays_and_back
 def bernoulli(input, *, generator=None, out=None):
     return ivy.bernoulli(input, out=out)
+
+
+@to_ivy_arrays_and_back
+def randperm(
+    n, 
+    *, 
+    generator=None, 
+    out=None, 
+    dtype=ivy.int64, 
+    layout=None, 
+    device=None, 
+    requires_grad=False, 
+    pin_memory=False
+):
+    arr = ivy.arange(n)
+    ret = ivy.shuffle(arr)
+    
+    return ret


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_torch/test_random_sampling.py b/ivy_tests/test_ivy/test_frontends/test_torch/test_random_sampling.py
--- a/ivy_tests/test_ivy/test_frontends/test_torch/test_random_sampling.py
+++ b/ivy_tests/test_ivy/test_frontends/test_torch/test_random_sampling.py
@@ -276,3 +276,43 @@ def call():
     for (u, v) in zip(ret_np, ret_from_np):
         assert u.dtype == v.dtype
         assert u.shape == v.shape
+
+
+@handle_frontend_test(
+    fn_tree="torch.randperm",
+    n=st.integers(min_value=0, max_value=10),
+    dtype=helpers.get_dtypes("integer", full=False),
+)
+def test_torch_randperm(
+    *,
+    n,
+    dtype,
+    on_device,
+    fn_tree,
+    frontend,
+    test_flags,
+):
+
+    def call():
+
+        return helpers.test_frontend_function(
+            input_dtypes=dtype,
+            frontend=frontend,
+            test_flags=test_flags,
+            fn_tree=fn_tree,
+            on_device=on_device,
+            test_values=False,
+            n=n,
+        )
+
+    ret = call()
+
+    if not ivy.exists(ret):
+        return
+
+    ret_np, ret_from_np = ret
+    ret_np = helpers.flatten_and_to_np(ret=ret_np)
+    ret_from_np = helpers.flatten_and_to_np(ret=ret_from_np)
+    for (u, v) in zip(ret_np, ret_from_np):
+        assert u.dtype == v.dtype
+        assert u.shape == v.shape
Repository: ivy-llc/ivy

Issue:
clone



Discussion:
This issue has been labelled as stale. If you would like to continue working on this issue, then please add another comment or create a PR . If a PR has already been created which refers to this issue, then you should explicitly mention this issue in the relevant PR. For more information please refer to this page in our documentation: https://lets-unify.ai/ivy/contributing/1_the_basics.html#todo-list-issues
I would love to continue the issue 
Continue working
This issue has been labelled as stale. If you would like to continue working on this issue, then please add another comment or create a PR . If a PR has already been created which refers to this issue, then you should explicitly mention this issue in the relevant PR. For more information please refer to this page in our documentation: https://lets-unify.ai/ivy/contributing/1_the_basics.html#todo-list-issues
https://github.com/unifyai/ivy/pull/14160
This issue has been labelled as stale. If you would like to continue working on this issue, then please add another comment or create a PR . If a PR has already been created which refers to this issue, then you should explicitly mention this issue in the relevant PR. For more information please refer to this page in our documentation: https://lets-unify.ai/ivy/contributing/1_the_basics.html#todo-list-issues
https://github.com/unifyai/ivy/pull/14251

Resolving patch:
diff --git a/ivy/functional/frontends/torch/miscellaneous_ops.py b/ivy/functional/frontends/torch/miscellaneous_ops.py
--- a/ivy/functional/frontends/torch/miscellaneous_ops.py
+++ b/ivy/functional/frontends/torch/miscellaneous_ops.py
@@ -376,3 +376,8 @@ def atleast_3d(*tensors):
 @to_ivy_arrays_and_back
 def diag(input, diagonal=0, *, out=None):
     return ivy.diag(input, k=diagonal)
+
+
+@to_ivy_arrays_and_back
+def clone(input):
+    return ivy.copy_array(input)


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_torch/test_miscellaneous_ops.py b/ivy_tests/test_ivy/test_frontends/test_torch/test_miscellaneous_ops.py
--- a/ivy_tests/test_ivy/test_frontends/test_torch/test_miscellaneous_ops.py
+++ b/ivy_tests/test_ivy/test_frontends/test_torch/test_miscellaneous_ops.py
@@ -1292,3 +1292,29 @@ def test_torch_diag(
         input=values[0],
         diagonal=diagonal,
     )
+
+
+# clone
+@handle_frontend_test(
+    fn_tree="torch.clone",
+    dtype_and_x=helpers.dtype_and_values(
+        available_dtypes=helpers.get_dtypes("valid"),
+    ),
+)
+def test_torch_clone(
+    *,
+    dtype_and_x,
+    on_device,
+    fn_tree,
+    frontend,
+    test_flags,
+):
+    input_dtype, x = dtype_and_x
+    helpers.test_frontend_function(
+        input_dtypes=input_dtype,
+        frontend=frontend,
+        test_flags=test_flags,
+        fn_tree=fn_tree,
+        on_device=on_device,
+        input=x[0],
+    )
Repository: ivy-llc/ivy

Issue:
nan_to_num



Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/torch/pointwise_ops.py b/ivy/functional/frontends/torch/pointwise_ops.py
--- a/ivy/functional/frontends/torch/pointwise_ops.py
+++ b/ivy/functional/frontends/torch/pointwise_ops.py
@@ -507,3 +507,9 @@ def sgn(input, *, out=None):
         )
     else:
         return ivy.sign(input, out=out)
+
+
+@with_unsupported_dtypes({"2.9.0 and below": ("bfloat16",)}, "tensorflow")
+@to_ivy_arrays_and_back
+def nan_to_num(input, nan=0.0, posinf=None, neginf=None, *, out=None):
+    return ivy.nan_to_num(input, nan=nan, posinf=posinf, neginf=neginf, out=out)


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_torch/test_pointwise_ops.py b/ivy_tests/test_ivy/test_frontends/test_torch/test_pointwise_ops.py
--- a/ivy_tests/test_ivy/test_frontends/test_torch/test_pointwise_ops.py
+++ b/ivy_tests/test_ivy/test_frontends/test_torch/test_pointwise_ops.py
@@ -2374,3 +2374,44 @@ def test_torch_sgn(
         input=input[0],
         out=None,
     )
+
+
+@handle_frontend_test(
+    fn_tree="torch.nan_to_num",
+    dtype_and_x=helpers.dtype_and_values(
+        available_dtypes=helpers.get_dtypes("float"),
+        min_num_dims=1,
+        max_num_dims=3,
+        min_value=-100,
+        max_value=100,
+        allow_nan=True,
+        allow_inf=True,
+    ),
+    nan=st.floats(min_value=-100.0, max_value=100.0),
+    posinf=st.just(None) | st.floats(min_value=5e100, max_value=5e100),
+    neginf=st.just(None) | st.floats(min_value=-5e100, max_value=-5e100),
+    test_with_out=st.just(False),
+)
+def test_torch_nan_to_num(
+    *,
+    dtype_and_x,
+    nan,
+    posinf,
+    neginf,
+    on_device,
+    fn_tree,
+    frontend,
+    test_flags,
+):
+    input_dtype, x = dtype_and_x
+    helpers.test_frontend_function(
+        input_dtypes=input_dtype,
+        frontend=frontend,
+        test_flags=test_flags,
+        fn_tree=fn_tree,
+        on_device=on_device,
+        input=x[0],
+        nan=nan,
+        posinf=posinf,
+        neginf=neginf,
+    )
Repository: ivy-llc/ivy

Issue:
log10



Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/torch/tensor.py b/ivy/functional/frontends/torch/tensor.py
--- a/ivy/functional/frontends/torch/tensor.py
+++ b/ivy/functional/frontends/torch/tensor.py
@@ -998,3 +998,7 @@ def mm(self, mat2):
     @with_unsupported_dtypes({"1.11.0 and below": ("bfloat16", "float16")}, "torch")
     def square(self):
         return torch_frontend.square(self._ivy_array)
+
+    @with_unsupported_dtypes({"1.11.0 and below": ("float16",)}, "torch")
+    def log10(self):
+        return torch_frontend.log10(self._ivy_array)


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py b/ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py
--- a/ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py
+++ b/ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py
@@ -7132,3 +7132,37 @@ def test_torch_instance_square(
         frontend=frontend,
         on_device=on_device,
     )
+
+
+# log10
+@handle_frontend_method(
+    class_tree=CLASS_TREE,
+    init_tree="torch.tensor",
+    method_name="log10",
+    dtype_and_x=helpers.dtype_and_values(
+        available_dtypes=helpers.get_dtypes("float"),
+        allow_inf=False,
+    ),
+)
+def test_torch_instance_log10(
+    dtype_and_x,
+    frontend_method_data,
+    init_flags,
+    method_flags,
+    frontend,
+    on_device,
+):
+    input_dtype, x = dtype_and_x
+    helpers.test_frontend_method(
+        init_input_dtypes=input_dtype,
+        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,
+    )
Repository: ivy-llc/ivy

Issue:
chisquare
Add chisquare sampling to Numpy frontend


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
@@ -95,3 +95,18 @@ def standard_normal(size=None):
 @from_zero_dim_arrays_to_scalar
 def standard_gamma(shape, size=None):
     return ivy.gamma(shape, 1.0, shape=size, dtype="float64")
+
+
+@to_ivy_arrays_and_back
+@from_zero_dim_arrays_to_scalar
+def chisquare(df, size=None):
+    df = ivy.array(df)  # scalar ints and floats are also array_like
+    if ivy.any(df <= 0):
+        raise ValueError("df <= 0")
+
+    # ivy.gamma() throws an error if both alpha is an array and a shape is passed
+    # so this part broadcasts df into the shape of `size`` first to keep it happy.
+    if size is not None:
+        df = df * ivy.ones(size)
+
+    return ivy.gamma(df / 2, 2, dtype="float64")


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
@@ -384,3 +384,63 @@ def test_numpy_standard_gamma(
         shape=shape,
         size=size,
     )
+
+
+# chisquare
+# The test values are restricted to (0, 1000] because df<=0 is invalid
+# and very large df can cause problems with type conversions
+@handle_frontend_test(
+    fn_tree="numpy.random.chisquare",
+    dtypes=helpers.get_dtypes("float", full=False),
+    df=st.one_of(
+        st.floats(
+            min_value=0,
+            max_value=1000,
+            exclude_min=True,
+            allow_subnormal=False,
+            width=32,
+        ),
+        st.integers(min_value=1, max_value=1000),
+        st.lists(
+            st.one_of(
+                st.floats(
+                    min_value=0,
+                    max_value=1000,
+                    exclude_min=True,
+                    allow_subnormal=False,
+                    width=32,
+                )
+                | st.integers(min_value=1, max_value=1000)
+            ),
+            min_size=1,
+        ),
+    ),
+    size=helpers.get_shape(allow_none=True),
+    test_with_out=st.just(False),
+)
+def test_numpy_chisquare(
+    dtypes,
+    df,
+    size,
+    frontend,
+    test_flags,
+    fn_tree,
+    on_device,
+):
+    # make sure `size` is something `df` can be broadcast to
+    if (
+        hasattr(df, "__len__")
+        and size is not None
+        and (len(size) == 0 or size[-1] != len(df))
+    ):
+        size = (*size, len(df))
+    helpers.test_frontend_function(
+        input_dtypes=dtypes,
+        frontend=frontend,
+        test_flags=test_flags,
+        fn_tree=fn_tree,
+        on_device=on_device,
+        test_values=False,
+        df=df,
+        size=size,
+    )