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

Issue:
nextafter



Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/jax/lax/operators.py b/ivy/functional/frontends/jax/lax/operators.py
--- a/ivy/functional/frontends/jax/lax/operators.py
+++ b/ivy/functional/frontends/jax/lax/operators.py
@@ -615,3 +615,8 @@ def squeeze(array, dimensions):
 @to_ivy_arrays_and_back
 def real(x):
     return ivy.real(x)
+
+
+@to_ivy_arrays_and_back
+def nextafter(x1, x2):
+    return ivy.nextafter(x1, x2)


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_lax_operators.py b/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_lax_operators.py
--- a/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_lax_operators.py
+++ b/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_lax_operators.py
@@ -2517,3 +2517,39 @@ def test_jax_lax_squeeze(
         array=value[0],
         dimensions=dim,
     )
+
+
+# nextafter
+@handle_frontend_test(
+    fn_tree="jax.lax.nextafter",
+    dtype_and_x=helpers.dtype_and_values(
+        available_dtypes=["float32", "float64"],
+        min_value=-100,
+        max_value=100,
+        min_num_dims=1,
+        max_num_dims=3,
+        min_dim_size=1,
+        max_dim_size=3,
+        num_arrays=2,
+        shared_dtype=True,
+    ),
+    test_with_out=st.just(False),
+)
+def test_jax_lax_nextafter(
+    *,
+    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,
+        x1=x[0],
+        x2=x[0],
+    )
Repository: ivy-llc/ivy

Issue:
generalized_normal



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
@@ -125,6 +125,14 @@ def gumbel(key, shape=(), dtype="float64"):
     },
     "jax",
 )
+def generalized_normal(key, p, shape=(), dtype="float64"):
+    seed = _get_seed(key)
+    g = ivy.gamma(1 / p, 1.0, shape=shape, dtype=dtype, seed=seed)
+    b = ivy.bernoulli(ivy.array([0.5]), shape=shape, dtype=dtype, seed=seed)
+    r = 2 * b - 1
+    return r * g ** (1 / p)
+
+
 def t(key, df, shape=(), dtype="float64"):
     seed = _get_seed(key)
     n = ivy.random_normal(shape=shape, dtype=dtype, seed=seed)


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_random.py b/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_random.py
--- a/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_random.py
+++ b/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_random.py
@@ -505,3 +505,63 @@ def call():
     for (u, v) in zip(ret_np, ret_from_np):
         assert u.dtype == v.dtype
         assert u.shape == v.shape
+
+
+# TODO Update the test by fixing the uint32 unsupported problem
+@pytest.mark.xfail
+@handle_frontend_test(
+    fn_tree="jax.random.generalized_normal",
+    dtype_key=helpers.dtype_and_values(
+        available_dtypes=["uint32"],
+        min_value=0,
+        max_value=2000,
+        min_num_dims=1,
+        max_num_dims=1,
+        min_dim_size=2,
+        max_dim_size=2,
+    ),
+    p=st.floats(min_value=1e-5, max_value=100, exclude_min=True),
+    shape=helpers.get_shape(
+        min_num_dims=1, max_num_dims=6, min_dim_size=1, max_dim_size=6
+    ),
+    dtype=helpers.get_dtypes("float", full=False),
+    test_with_out=st.just(False),
+)
+def test_jax_generalized_normal(
+    *,
+    dtype_key,
+    p,
+    shape,
+    dtype,
+    on_device,
+    fn_tree,
+    frontend,
+    test_flags,
+):
+    input_dtype, key = dtype_key
+
+    def call():
+        return helpers.test_frontend_function(
+            input_dtypes=input_dtype,
+            frontend=frontend,
+            test_flags=test_flags,
+            fn_tree=fn_tree,
+            on_device=on_device,
+            test_values=False,
+            key=key[0],
+            p=p,
+            shape=shape,
+            dtype=dtype[0],
+        )
+
+    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:
cauchy



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
@@ -64,6 +64,14 @@ def dirichlet(key, alpha, shape=None, dtype="float32"):
     return ivy.dirichlet(alpha, size=shape, dtype=dtype, seed=seed)
 
 
+@handle_jax_dtype
+@to_ivy_arrays_and_back
+def cauchy(key, shape=(), dtype="float64"):
+    seed = _get_seed(key)
+    u = ivy.random_uniform(low=0.0, high=1.0, shape=shape, dtype=dtype, seed=seed)
+    return ivy.tan(ivy.pi * (u - 0.5))
+
+
 @handle_jax_dtype
 @to_ivy_arrays_and_back
 @with_unsupported_dtypes(


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_random.py b/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_random.py
--- a/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_random.py
+++ b/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_random.py
@@ -253,6 +253,58 @@ def call():
         assert u.shape == v.shape
 
 
+@handle_frontend_test(
+    fn_tree="jax.random.cauchy",
+    dtype_key=helpers.dtype_and_values(
+        available_dtypes=["uint32"],
+        min_value=0,
+        max_value=2000,
+        min_num_dims=1,
+        max_num_dims=1,
+        min_dim_size=2,
+        max_dim_size=2,
+    ),
+    shape=helpers.get_shape(),
+    dtype=helpers.get_dtypes("float", full=False),
+)
+def test_jax_cauchy(
+    *,
+    dtype_key,
+    shape,
+    dtype,
+    on_device,
+    fn_tree,
+    frontend,
+    test_flags,
+):
+    input_dtype, key = dtype_key
+
+    def call():
+        return helpers.test_frontend_function(
+            input_dtypes=input_dtype,
+            frontend=frontend,
+            test_flags=test_flags,
+            fn_tree=fn_tree,
+            on_device=on_device,
+            test_values=False,
+            key=key[0],
+            shape=shape,
+            dtype=dtype[0],
+        )
+
+    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="jax.random.poisson",
     dtype_key=helpers.dtype_and_values(
Repository: ivy-llc/ivy

Issue:
signbit



Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/jax/numpy/mathematical_functions.py b/ivy/functional/frontends/jax/numpy/mathematical_functions.py
--- a/ivy/functional/frontends/jax/numpy/mathematical_functions.py
+++ b/ivy/functional/frontends/jax/numpy/mathematical_functions.py
@@ -607,3 +607,9 @@ def polymul(a1, a2, *, trim_leading_zeros=False):
     if len(a2) == 0:
         a2 = ivy.asarray([0], dtype=a2.dtype)
     return convolve(a1, a2, mode="full")
+
+
+@to_ivy_arrays_and_back
+def signbit(x, /):
+    x = ivy.array(x)
+    return ivy.signbit(x)


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_numpy_math.py b/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_numpy_math.py
--- a/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_numpy_math.py
+++ b/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_numpy_math.py
@@ -2773,3 +2773,29 @@ def test_jax_numpy_polymul(
         atol=1e-05,
         rtol=1e-03,
     )
+
+
+# signbit
+@handle_frontend_test(
+    fn_tree="jax.numpy.signbit",
+    dtype_and_x=helpers.dtype_and_values(
+        available_dtypes=helpers.get_dtypes("float"),
+    ),
+)
+def test_jax_numpy_signbit(
+    *,
+    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,
+        x=x[0],
+    )
Repository: ivy-llc/ivy

Issue:
fori_loop



Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/jax/lax/control_flow_operators.py b/ivy/functional/frontends/jax/lax/control_flow_operators.py
--- a/ivy/functional/frontends/jax/lax/control_flow_operators.py
+++ b/ivy/functional/frontends/jax/lax/control_flow_operators.py
@@ -34,3 +34,15 @@ def switch(index, branches, *operands, operand=None):
     index = max(index, 0)
     index = min(len(branches) - 1, index)
     return branches[index](*operands)
+
+
+@to_ivy_arrays_and_back
+def fori_loop(lower, upper, body_fun, init_val):
+    if not (callable(body_fun)):
+        raise ivy.exceptions.IvyException(
+            "jax.lax.fori_loop: Argument body_fun should be callable."
+        )
+    val = init_val
+    for i in range(lower, upper):
+        val = body_fun(i, val)
+    return val


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_lax_control_flow_operators.py b/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_lax_control_flow_operators.py
--- a/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_lax_control_flow_operators.py
+++ b/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_lax_control_flow_operators.py
@@ -113,3 +113,43 @@ def _test_branch_2(x):
         branches=[_test_branch_1, _test_branch_2],
         operand=x[0],
     )
+
+
+@handle_frontend_test(
+    fn_tree="jax.lax.fori_loop",
+    dtype_and_x=helpers.dtype_and_values(
+        available_dtypes=helpers.get_dtypes("numeric"),
+        min_value=-1000,
+        max_value=1000,
+        min_num_dims=1,
+        min_dim_size=1,
+    ),
+    lower=st.integers(min_value=-10, max_value=10),
+    upper=st.integers(min_value=-10, max_value=10),
+    test_with_out=st.just(False),
+)
+def test_jax_lax_fori_loop(
+    *,
+    dtype_and_x,
+    lower,
+    upper,
+    test_flags,
+    on_device,
+    fn_tree,
+    frontend,
+):
+    def _test_body_fn(x, y):
+        return x + y
+
+    input_dtype, x = dtype_and_x
+    helpers.test_frontend_function(
+        input_dtypes=input_dtype,
+        test_flags=test_flags,
+        frontend=frontend,
+        fn_tree=fn_tree,
+        on_device=on_device,
+        lower=lower,
+        upper=upper,
+        body_fun=_test_body_fn,
+        init_val=x[0],
+    )
Repository: ivy-llc/ivy

Issue:
angle



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

Resolving patch:
diff --git a/ivy/functional/frontends/tensorflow/math.py b/ivy/functional/frontends/tensorflow/math.py
--- a/ivy/functional/frontends/tensorflow/math.py
+++ b/ivy/functional/frontends/tensorflow/math.py
@@ -637,6 +637,11 @@ def cosh(x, name=None):
     return ivy.cosh(x)
 
 
+@to_ivy_arrays_and_back
+def angle(input, name=None):
+    return ivy.angle(input)
+    
+    
 @to_ivy_arrays_and_back
 @with_supported_dtypes(
     {


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_math.py b/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_math.py
--- a/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_math.py
+++ b/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_math.py
@@ -2389,6 +2389,32 @@ def test_tensorflow_less(
     )
 
 
+# angle
+@handle_frontend_test(
+    fn_tree="tensorflow.math.angle",
+    dtype_and_input=helpers.dtype_and_values(
+        available_dtypes=["float64", "complex64", "complex128"],
+    ),
+)
+def test_tensorflow_angle(
+    *,
+    dtype_and_input,
+    frontend,
+    test_flags,
+    fn_tree,
+    on_device,
+):
+    input_dtype, x = dtype_and_input
+    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],
+    )
+
+
 # zeta
 @handle_frontend_test(
     fn_tree="tensorflow.math.zeta",
Repository: ivy-llc/ivy

Issue:
Fix inserting_data_into_arrays.test_numpy_fill_diagonal
|   |   |
|---|---|
|paddle|<a href="https://github.com/unifyai/ivy/actions/runs/6260993885"><img src=https://img.shields.io/badge/-success-success></a>
|tensorflow|<a href="https://github.com/unifyai/ivy/actions/runs/6260993885"><img src=https://img.shields.io/badge/-success-success></a>
|torch|<a href="https://github.com/unifyai/ivy/actions/runs/6260993885"><img src=https://img.shields.io/badge/-success-success></a>
|numpy|<a href="https://github.com/unifyai/ivy/actions/runs/6260993885"><img src=https://img.shields.io/badge/-success-success></a>
|jax|<a href="https://github.com/unifyai/ivy/actions/runs/6260993885"><img src=https://img.shields.io/badge/-success-success></a>



Discussion:
start working

Resolving patch:
diff --git a/ivy/functional/frontends/numpy/indexing_routines/inserting_data_into_arrays.py b/ivy/functional/frontends/numpy/indexing_routines/inserting_data_into_arrays.py
--- a/ivy/functional/frontends/numpy/indexing_routines/inserting_data_into_arrays.py
+++ b/ivy/functional/frontends/numpy/indexing_routines/inserting_data_into_arrays.py
@@ -25,6 +25,6 @@ def fill_diagonal(a, val, wrap=False):
 
     # Write the value out into the diagonal.
     shape = a.shape
-    a = ivy.reshape(a, a.size)
-    a[:end:step] = val
-    a = ivy.reshape(a, shape)
+    temp = ivy.flatten(a)
+    temp[:end:step] = val
+    a = ivy.reshape(temp, shape)


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_numpy/test_indexing_routines/test_inserting_data_into_arrays.py b/ivy_tests/test_ivy/test_frontends/test_numpy/test_indexing_routines/test_inserting_data_into_arrays.py
--- a/ivy_tests/test_ivy/test_frontends/test_numpy/test_indexing_routines/test_inserting_data_into_arrays.py
+++ b/ivy_tests/test_ivy/test_frontends/test_numpy/test_indexing_routines/test_inserting_data_into_arrays.py
@@ -16,7 +16,7 @@
         min_dim_size=2,
         max_num_dims=2,
     ),
-    val=helpers.floats(),
+    val=helpers.floats(min_value=-10, max_value=10),
     wrap=helpers.get_dtypes(kind="bool"),
     test_with_out=st.just(False),
 )
Repository: ivy-llc/ivy

Issue:
Fix generating_index_arrays.test_numpy_diag_indices
|   |   |
|---|---|
|paddle|<a href="https://github.com/unifyai/ivy/actions/runs/6413197943/job/17411744582"><img src=https://img.shields.io/badge/-failure-red></a>
|tensorflow|<a href="https://github.com/unifyai/ivy/actions/runs/6413197943/job/17411744582"><img src=https://img.shields.io/badge/-failure-red></a>
|torch|<a href="https://github.com/unifyai/ivy/actions/runs/6413197943/job/17411744582"><img src=https://img.shields.io/badge/-failure-red></a>
|numpy|<a href="https://github.com/unifyai/ivy/actions/runs/6413197943/job/17411744582"><img src=https://img.shields.io/badge/-failure-red></a>
|jax|<a href="https://github.com/unifyai/ivy/actions/runs/6413197943/job/17411744582"><img src=https://img.shields.io/badge/-failure-red></a>



Discussion:
start working

Resolving patch:
diff --git a/ivy/functional/frontends/numpy/indexing_routines/generating_index_arrays.py b/ivy/functional/frontends/numpy/indexing_routines/generating_index_arrays.py
--- a/ivy/functional/frontends/numpy/indexing_routines/generating_index_arrays.py
+++ b/ivy/functional/frontends/numpy/indexing_routines/generating_index_arrays.py
@@ -30,10 +30,12 @@ def unravel_index(indices, shape, order="C"):
     return tuple(ret)
 
 
-@outputs_to_numpy_arrays
+@to_ivy_arrays_and_back
 def diag_indices(n, ndim=2):
-    idx = ivy.arange(n, dtype=int)
-    return (idx,) * ndim
+    idx = ivy.arange(n)
+    res = ivy.array((idx,) * ndim)
+    res = tuple(res.astype("int64"))
+    return res
 
 
 @to_ivy_arrays_and_back


Test patch:
Repository: ivy-llc/ivy

Issue:
cond



Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/tensorflow/general_functions.py b/ivy/functional/frontends/tensorflow/general_functions.py
--- a/ivy/functional/frontends/tensorflow/general_functions.py
+++ b/ivy/functional/frontends/tensorflow/general_functions.py
@@ -156,6 +156,25 @@ def concat(values, axis, name=None):
     return ivy.concat(values, axis=axis)
 
 
+@to_ivy_arrays_and_back
+def cond(pred, true_fn=None, false_fn=None, name=None):
+    if true_fn is None:
+        raise TypeError("cond(): 'true_fn' argument required")
+    if false_fn is None:
+        raise TypeError("cond(): 'false_fn' argument required")
+
+    if not callable(true_fn):
+        raise TypeError("'true_fn' must be callable.")
+    if not callable(false_fn):
+        raise TypeError("'false_fn' must be callable.")
+
+    if pred:
+        return true_fn()
+
+    if not pred:
+        return false_fn()
+    
+
 @to_ivy_arrays_and_back
 def shape(input, out_type=ivy.int32, name=None):
     out_type = to_ivy_dtype(out_type)


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_general_functions.py b/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_general_functions.py
--- a/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_general_functions.py
+++ b/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_general_functions.py
@@ -745,6 +745,47 @@ def test_tensorflow_concat(
         axis=axis,
     )
 
+    
+    
+# cond
+@handle_frontend_test(
+    fn_tree="tensorflow.cond",
+    dtype_and_x=helpers.dtype_and_values(
+        available_dtypes=helpers.get_dtypes("numeric"),
+        min_num_dims=1,
+        min_dim_size=1,
+    ),
+    pred_cond=st.booleans(),
+    var=st.integers(min_value=1, max_value=100),
+    test_with_out=st.just(False),
+)
+def test_tensorflow_cond(
+        *,
+        dtype_and_x,
+        pred_cond,
+        var,
+        test_flags,
+        on_device,
+        fn_tree,
+        frontend,
+):
+    _test_true_fn = lambda: var + var
+
+    _test_false_fn = lambda: var * var
+
+    input_dtype, _ = dtype_and_x
+    helpers.test_frontend_function(
+        input_dtypes=input_dtype,
+        test_flags=test_flags,
+        frontend=frontend,
+        fn_tree=fn_tree,
+        on_device=on_device,
+        pred=pred_cond,
+        true_fn=_test_true_fn,
+        false_fn=_test_false_fn,
+    )
+
+
 
 # zeros
 @handle_frontend_test(
Repository: ivy-llc/ivy

Issue:
scan



Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/tensorflow/general_functions.py b/ivy/functional/frontends/tensorflow/general_functions.py
--- a/ivy/functional/frontends/tensorflow/general_functions.py
+++ b/ivy/functional/frontends/tensorflow/general_functions.py
@@ -471,6 +471,22 @@ def reverse(tensor, axis, name=None):
     return ivy.flip(tensor, axis=axis)
 
 
+@to_ivy_arrays_and_back
+def scan(
+    fn,
+    elems,
+    initializer=None,
+    parallel_iterations=10,
+    back_prop=True,
+    swap_memory=False,
+    infer_shape=True,
+    reverse=False,
+    name=None
+):
+    elems = ivy.asarray(elems)
+    return ivy.associative_scan(elems, fn, reverse=reverse)
+
+
 @to_ivy_arrays_and_back
 def norm(tensor, ord="euclidean", axis=None, keepdims=None, name=None):
     return tf_frontend.linalg.norm(


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_general_functions.py b/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_general_functions.py
--- a/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_general_functions.py
+++ b/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_general_functions.py
@@ -1831,6 +1831,40 @@ def test_tensorflow_reverse(
     )
 
 
+# scan
+@handle_frontend_test(
+    fn_tree="tensorflow.scan",
+    dtypes_values=helpers.dtype_and_values(
+        available_dtypes=['float32'],
+        num_arrays=1,
+        min_num_dims=2,
+        max_dim_size=3
+    ),
+    test_with_out=st.just(False),
+)
+def test_tensorflow_scan(
+    *,
+    dtypes_values,
+    on_device,
+    fn_tree,
+    frontend,
+    test_flags,
+):
+    def _test_fn(a, x):
+        return a + x
+
+    x_dtype, elems = dtypes_values
+    helpers.test_frontend_function(
+        input_dtypes=x_dtype,
+        frontend=frontend,
+        test_flags=test_flags,
+        fn_tree=fn_tree,
+        on_device=on_device,
+        fn=_test_fn,
+        elems=elems[0],
+    )
+
+
 @handle_frontend_test(
     fn_tree="tensorflow.norm",
     aliases=["tensorflow.norm"],
Repository: ivy-llc/ivy

Issue:
in_top_k
Math functions for TensorFlow frontend


Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/tensorflow/math.py b/ivy/functional/frontends/tensorflow/math.py
--- a/ivy/functional/frontends/tensorflow/math.py
+++ b/ivy/functional/frontends/tensorflow/math.py
@@ -662,3 +662,9 @@ def zeta(x, q, name=None):
 def greater_equal(x, y, name=None):
     x, y = check_tensorflow_casting(x, y)
     return ivy.greater_equal(x, y)
+
+
+@to_ivy_arrays_and_back
+def in_top_k(target, pred, k, name=None):
+    top_k = ivy.top_k(target, k)
+    return ivy.array([val in top_k.values for val in target])
\ No newline at end of file


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_math.py b/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_math.py
--- a/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_math.py
+++ b/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_math.py
@@ -2500,3 +2500,36 @@ def test_tensorflow_greater_equal(
         x=x[0],
         y=x[1],
     )
+    
+    
+# in_top_k
+@handle_frontend_test(
+    fn_tree="tensorflow.math.in_top_k",
+    dtype_and_x=helpers.dtype_and_values(
+        available_dtypes=helpers.get_dtypes("numeric"),
+        num_arrays=2,
+        shared_dtype=True,
+    ),
+    k=st.integers(min_value=0, max_value=5),
+    test_with_out=st.just(False),
+)
+def test_tensorflow_in_top_k(
+    *,
+    dtype_and_x,
+    frontend,
+    test_flags,
+    fn_tree,
+    on_device,
+    k
+):
+    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,
+        targets=x[0],
+        pred=x[1],
+        k=k
+    )
\ No newline at end of file
diff --git a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_ayad.py b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_ayad.py
new file mode 100644
--- /dev/null
+++ b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_ayad.py
@@ -0,0 +1,39 @@
+# global
+from hypothesis import strategies as st
+
+# local
+import ivy_tests.test_ivy.helpers as helpers
+from ivy_tests.test_ivy.helpers import handle_frontend_test
+
+
+# in_top_k
+@handle_frontend_test(
+    fn_tree="tensorflow.math.in_top_k",
+    dtype_and_x=helpers.dtype_and_values(
+        available_dtypes=helpers.get_dtypes("numeric"),
+        num_arrays=2,
+        shared_dtype=True,
+    ),
+    k=st.integers(min_value=0, max_value=5),
+    test_with_out=st.just(False),
+)
+def test_tensorflow_in_top_k(
+    *,
+    dtype_and_x,
+    frontend,
+    test_flags,
+    fn_tree,
+    on_device,
+    k
+):
+    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,
+        target=x[0],
+        pred=x[1],
+        k=k
+    )
\ No newline at end of file