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

Issue:
Fix nn.test_tensorflow_avg_pool2d
|   |   |
|---|---|
|paddle|<a href="https://github.com/unifyai/ivy/actions/runs/6417933583"><img src=https://img.shields.io/badge/-success-success></a>
|numpy|<a href="https://github.com/unifyai/ivy/actions/runs/6359267273/job/17272232870"><img src=https://img.shields.io/badge/-success-success></a>
|jax|<a href="https://github.com/unifyai/ivy/actions/runs/6359267273/job/17272232870"><img src=https://img.shields.io/badge/-failure-red></a>
|tensorflow|<a href="https://github.com/unifyai/ivy/actions/runs/6359267273/job/17272232870"><img src=https://img.shields.io/badge/-success-success></a>
|torch|<a href="https://github.com/unifyai/ivy/actions/runs/6359267273/job/17272232870"><img src=https://img.shields.io/badge/-success-success></a>



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
@@ -91,7 +91,9 @@ def avg_pool1d(input, ksize, strides, padding, data_format="NWC", name=None):
 # 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)
+    return ivy.avg_pool2d(
+        input, ksize, strides, padding, data_format=data_format
+    ).astype(input.dtype)
 
 
 # avg_pool3d


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
@@ -704,6 +704,8 @@ def test_tensorflow_avg_pool2d(
         ksize=ksize,
         strides=strides,
         padding=padding,
+        rtol=1e-2,
+        atol=1e-2,
     )
Repository: ivy-llc/ivy

Issue:
tile



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
@@ -4,6 +4,7 @@
 from ivy.func_wrapper import (
     with_supported_dtypes,
     with_unsupported_dtypes,
+    with_supported_device_and_dtypes,
 )
 from ivy.functional.frontends.paddle.func_wrapper import _to_ivy_array
 
@@ -908,3 +909,22 @@ def gather(self, y, name=None):
     def gather_(self, y, name=None):
         res = self.gather(self, y)
         return ivy.inplace_update(self, res)
+
+    @with_supported_device_and_dtypes(
+        {
+            "2.5.1 and below": {
+                "cpu": (
+                    "bool",
+                    "int32",
+                    "int64",
+                    "float32",
+                    "float64",
+                    "complex64",
+                    "complex128",
+                )
+            }
+        },
+        "paddle",
+    )
+    def tile(self, repeat_times):
+        return paddle_frontend.Tensor(ivy.tile(self._ivy_array, repeats=repeat_times))


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
@@ -19,6 +19,9 @@
 from ivy_tests.test_ivy.test_frontends.test_torch.test_blas_and_lapack_ops import (
     _get_dtype_and_3dbatch_matrices,
 )
+from ivy_tests.test_ivy.test_frontends.test_paddle.test_manipulation import (
+    _tile_helper,
+)
 
 CLASS_TREE = "ivy.functional.frontends.paddle.Tensor"
 
@@ -4480,6 +4483,39 @@ def test_paddle_tensor_tanh_(
     )
 
 
+# tile
+@handle_frontend_method(
+    class_tree=CLASS_TREE,
+    init_tree="paddle.to_tensor",
+    method_name="tile",
+    dt_x_repeats=_tile_helper(),
+)
+def test_paddle_tensor_tile(
+    dt_x_repeats,
+    frontend,
+    backend_fw,
+    frontend_method_data,
+    init_flags,
+    method_flags,
+    on_device,
+):
+    input_dtypes, x, repeats = dt_x_repeats
+    helpers.test_frontend_method(
+        init_input_dtypes=input_dtypes,
+        init_all_as_kwargs_np={"data": x[0]},
+        method_input_dtypes=input_dtypes,
+        method_all_as_kwargs_np={
+            "repeat_times": repeats,
+        },
+        frontend=frontend,
+        frontend_method_data=frontend_method_data,
+        init_flags=init_flags,
+        backend_to_test=backend_fw,
+        method_flags=method_flags,
+        on_device=on_device,
+    )
+
+
 # topk
 @handle_frontend_method(
     class_tree=CLASS_TREE,
Repository: ivy-llc/ivy

Issue:
Pointless statement in the file `ivy\data_classes\nested_array\base.py`
In the file [`ivy\data_classes\nested_array\base.py`](https://github.com/unifyai/ivy/blob/main/ivy/data_classes/nested_array/base.py) the code/statement in line 144 seems to have no effect. So, it should be removed. I was able to detect it using [Pylint](https://pylint.readthedocs.io/en/latest/user_guide/messages/warning/pointless-statement.html).
https://github.com/unifyai/ivy/blob/11c584fcdcd3732b42de7b4241b7a8bc5e7796fb/ivy/data_classes/nested_array/base.py#L144


Discussion:

Resolving patch:
diff --git a/ivy/data_classes/nested_array/base.py b/ivy/data_classes/nested_array/base.py
--- a/ivy/data_classes/nested_array/base.py
+++ b/ivy/data_classes/nested_array/base.py
@@ -141,7 +141,6 @@ def ragged_multi_map(fn, ragged_arrays):
         args = list()
         for ragged in ragged_arrays:
             args.append(ivy.copy_nest(ragged.data))
-        ragged_arrays[0]
         ret = ivy.nested_multi_map(lambda x, _: fn(x), args)
         # infer dtype, shape, and device from the first array in the ret data
         broadcasted_shape = ivy.NestedArray.broadcast_shapes(


Test patch:
Repository: ivy-llc/ivy

Issue:
complex



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
@@ -184,6 +184,11 @@ def clamp(min, x, max):
     return ivy.clip(x, min, max)
 
 
+@to_ivy_arrays_and_back
+def complex(x, y):
+    return ivy.complex(x, y)
+
+
 @to_ivy_arrays_and_back
 def concatenate(operands, dimension):
     return ivy.concat(operands, axis=dimension)


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_jax/test_lax/test_operators.py b/ivy_tests/test_ivy/test_frontends/test_jax/test_lax/test_operators.py
--- a/ivy_tests/test_ivy/test_frontends/test_jax/test_lax/test_operators.py
+++ b/ivy_tests/test_ivy/test_frontends/test_jax/test_lax/test_operators.py
@@ -1114,6 +1114,38 @@ def test_jax_clamp(
     )
 
 
+# complex
+@handle_frontend_test(
+    fn_tree="jax.lax.complex",
+    dtype_and_x=helpers.dtype_and_values(
+        available_dtypes=helpers.get_dtypes("numeric"),
+        num_arrays=2,
+        shared_dtype=True,
+    ),
+    test_with_out=st.just(False),
+)
+def test_jax_complex(
+    *,
+    dtype_and_x,
+    on_device,
+    fn_tree,
+    frontend,
+    test_flags,
+    backend_fw,
+):
+    input_dtype, x = dtype_and_x
+    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,
+        x=x[0],
+        y=x[1],
+    )
+
+
 # concat
 @handle_frontend_test(
     fn_tree="jax.lax.concatenate",
Repository: ivy-llc/ivy

Issue:
 bind_custom_gradient_function



Discussion:

Resolving patch:
diff --git a/ivy/functional/backends/paddle/experimental/gradients.py b/ivy/functional/backends/paddle/experimental/gradients.py
--- a/ivy/functional/backends/paddle/experimental/gradients.py
+++ b/ivy/functional/backends/paddle/experimental/gradients.py
@@ -1,7 +1,27 @@
 # global
+import paddle
 
-from ivy.utils.exceptions import IvyNotImplementedException
+# local
+import ivy
+from ivy.func_wrapper import inputs_to_native_arrays
 
 
 def bind_custom_gradient_function(func, custom_grad_fn):
-    raise IvyNotImplementedException()
+    class _CustomModule(paddle.autograd.PyLayer):
+        @staticmethod
+        def forward(ctx, x):
+            ret = ivy.to_native(func(x), nested=True, include_derived=True)
+            ctx.save_for_backward(x, ret)
+            return ret
+
+        @staticmethod
+        def backward(ctx, upstream):
+            grads = custom_grad_fn(
+                *ivy.to_ivy(
+                    (ctx.saved_tensor(), upstream), nested=True, include_derived=True
+                )
+            )
+            return ivy.to_native(grads, nested=True, include_derived=True)
+
+    custom_module = _CustomModule.apply
+    return inputs_to_native_arrays(custom_module)


Test patch:
Repository: ivy-llc/ivy

Issue:
standard_exponential



Discussion:
#21021
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/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
@@ -233,6 +233,15 @@ def standard_cauchy(size=None):
     return ivy.tan(ivy.pi * (u - 0.5))
 
 
+@to_ivy_arrays_and_back
+@from_zero_dim_arrays_to_scalar
+def standard_exponential(size=None):
+    if size is None:
+        size = 1
+    U = ivy.random_uniform(low=0.0, high=1.0, shape=size, dtype="float64")
+    return -ivy.log(U)
+
+
 @to_ivy_arrays_and_back
 @from_zero_dim_arrays_to_scalar
 def standard_gamma(shape, 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
@@ -895,6 +895,33 @@ def test_numpy_standard_cauchy(
     )
 
 
+@handle_frontend_test(
+    fn_tree="numpy.random.standard_exponential",
+    input_dtypes=helpers.get_dtypes("float", index=2),
+    size=helpers.get_shape(allow_none=True),
+    test_with_out=st.just(False),
+)
+def test_numpy_standard_exponential(
+    input_dtypes,
+    frontend,
+    test_flags,
+    backend_fw,
+    fn_tree,
+    on_device,
+    size,
+):
+    helpers.test_frontend_function(
+        input_dtypes=input_dtypes,
+        backend_to_test=backend_fw,
+        frontend=frontend,
+        test_flags=test_flags,
+        fn_tree=fn_tree,
+        on_device=on_device,
+        test_values=False,
+        size=size,
+    )
+
+
 @handle_frontend_test(
     fn_tree="numpy.random.standard_gamma",
     shape_dtypes=helpers.get_dtypes("float", full=False),
Repository: ivy-llc/ivy

Issue:
 floor_mod



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
@@ -228,6 +228,14 @@ def floor_divide(x, y, name=None):
     return ivy.floor_divide(x, y)
 
 
+@with_supported_dtypes(
+    {"2.5.1 and below": ("float32", "float64", "int32", "int64")}, "paddle"
+)
+@to_ivy_arrays_and_back
+def floor_mod(x, y, name=None):
+    return ivy.remainder(x, y)
+
+
 @with_unsupported_dtypes({"2.5.1 and below": "bfloat16"}, "paddle")
 @to_ivy_arrays_and_back
 def fmax(x, y, name=None):


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
@@ -943,6 +943,42 @@ def test_paddle_floor_divide(
     )
 
 
+# floor_mod
+@handle_frontend_test(
+    fn_tree="paddle.floor_mod",
+    dtype_and_x=helpers.dtype_and_values(
+        available_dtypes=helpers.get_dtypes("valid"),
+        num_arrays=2,
+        allow_inf=False,
+        large_abs_safety_factor=2,
+        small_abs_safety_factor=2,
+        safety_factor_scale="log",
+        shared_dtype=True,
+        min_value=1,
+    ),
+)
+def test_paddle_floor_mod(
+    *,
+    dtype_and_x,
+    on_device,
+    fn_tree,
+    frontend,
+    backend_fw,
+    test_flags,
+):
+    input_dtype, x = dtype_and_x
+    helpers.test_frontend_function(
+        input_dtypes=input_dtype,
+        frontend=frontend,
+        backend_to_test=backend_fw,
+        test_flags=test_flags,
+        fn_tree=fn_tree,
+        on_device=on_device,
+        x=x[0],
+        y=x[1],
+    )
+
+
 @handle_frontend_test(
     fn_tree="paddle.fmax",
     dtypes_and_x=helpers.dtype_and_values(
Repository: ivy-llc/ivy

Issue:
all_nested_indices



Discussion:

Resolving patch:
diff --git a/ivy/functional/ivy/nest.py b/ivy/functional/ivy/nest.py
--- a/ivy/functional/ivy/nest.py
+++ b/ivy/functional/ivy/nest.py
@@ -837,23 +837,40 @@ def all_nested_indices(
     ret
         A set of indices of all elements in nest
 
-    Both the description and the type hints above assumes an array input
-    for simplicity, but this function is nestable, and therefore also
-    accepts :class:ivy.Container instances in place of the arguments.
-
     Examples
     --------
-    With :class:`Dict` input:
+    With :code:`List` input:
+
+    >>> x = [189, [863, 672], [264, 384]]
+    >>> y = ivy.all_nested_indices(x)
+    >>> print(y)
+    [[0], [1, 0], [1, 1], [2, 0], [2, 1]]
+
+    With :code:`Tuple` input:
+
+    >>> x = (189, (863, 672), (264, 384))
+    >>> y = ivy.all_nested_indices(x, include_nests=True)
+    >>> print(y)
+    [[0], [1, 0], [1, 1], [1], [2, 0], [2, 1], [2]]
+
+    With :code:`Dict` input:
 
     >>> x = {'a': 2., 'b': [6., [15., 9.]], 'c': (7., 56.)}
     >>> y = ivy.all_nested_indices(x)
     >>> print(y)
     [['a'], ['b', 0], ['b', 1, 0], ['b', 1, 1], ['c', 0], ['c', 1]]
 
+    With :class:`ivy.Array` input:
+
+    >>> x = ivy.array([[True, False], [False, False]])
+    >>> y = ivy.all_nested_indices(x)
+    >>> print(y)
+    [[]]
+
     With :class:`ivy.Container` input:
 
-    >>> x = ivy.Container(a=ivy.array([0., 1., 2.]), b=ivy.array([3., 4., 5.]))
-    >>> y = ivy.all_nested_indices(x, True)
+    >>> x = ivy.Container(a=ivy.array([412, 948, 482]), b=ivy.array([168, 674, 341]))
+    >>> y = ivy.all_nested_indices(x)
     >>> print(y)
     [['a'], ['b']]
     """


Test patch:
Repository: ivy-llc/ivy

Issue:
expand



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
@@ -927,6 +927,12 @@ def gather_(self, y, name=None):
         res = self.gather(self, y)
         return ivy.inplace_update(self, res)
 
+    @with_supported_dtypes(
+        {"2.5.1 and below": ("bool", "int32", "int64", "float32", "float64")}, "paddle"
+    )
+    def expand(self, shape, name=None):
+        return paddle_frontend.expand(self._ivy_array, shape)
+
     @with_supported_device_and_dtypes(
         {
             "2.5.1 and below": {


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
@@ -225,6 +225,35 @@ def _reshape_helper(draw):
     return dtypes, x, reshape_shape
 
 
+# expand helper function
+@st.composite
+def dtypes_x_shape(draw):
+    dtypes, x = draw(
+        helpers.dtype_and_values(
+            min_dim_size=1,
+            min_num_dims=1,
+            available_dtypes=["float32"],
+            shape=st.shared(
+                helpers.get_shape(
+                    min_num_dims=1,
+                    max_num_dims=6,
+                ),
+                key="shape",
+            ),
+        )
+    )
+    shape = draw(
+        st.shared(
+            helpers.get_shape(
+                min_num_dims=1,
+                max_num_dims=6,
+            ),
+            key="shape",
+        )
+    )
+    return dtypes, x, shape
+
+
 # diagonal
 @st.composite
 def dims_and_offset(draw, shape):
@@ -2151,6 +2180,41 @@ def test_paddle_exp_(
     )
 
 
+# expand
+@handle_frontend_method(
+    class_tree=CLASS_TREE,
+    init_tree="paddle.to_tensor",
+    method_name="expand",
+    dtype_x_shape=dtypes_x_shape(),
+)
+def test_paddle_tensor_expand(
+    dtype_x_shape,
+    frontend_method_data,
+    init_flags,
+    method_flags,
+    frontend,
+    on_device,
+    backend_fw,
+):
+    input_dtype, x, shape = dtype_x_shape
+    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={
+            "shape": shape,
+        },
+        frontend_method_data=frontend_method_data,
+        init_flags=init_flags,
+        method_flags=method_flags,
+        frontend=frontend,
+        on_device=on_device,
+    )
+
+
 # fill_
 @handle_frontend_method(
     class_tree=CLASS_TREE,
Repository: ivy-llc/ivy

Issue:
qr



Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/jax/lax/linalg.py b/ivy/functional/frontends/jax/lax/linalg.py
--- a/ivy/functional/frontends/jax/lax/linalg.py
+++ b/ivy/functional/frontends/jax/lax/linalg.py
@@ -1,5 +1,6 @@
 import ivy
 from ivy.functional.frontends.jax.func_wrapper import to_ivy_arrays_and_back
+from ivy.func_wrapper import with_unsupported_dtypes
 
 
 @to_ivy_arrays_and_back
@@ -33,6 +34,15 @@ def symmetrize(x):
     return ivy.eigh(x, UPLO=UPLO)
 
 
+@to_ivy_arrays_and_back
+@with_unsupported_dtypes({"0.4.14 and below": ("bfloat16",)}, "jax")
+def qr(x, /, *, full_matrices=False):
+    mode = "reduced"
+    if full_matrices is True:
+        mode = "complete"
+    return ivy.qr(x, mode=mode)
+
+
 @to_ivy_arrays_and_back
 def svd(x, /, *, full_matrices=True, compute_uv=True):
     if not compute_uv:


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_jax/test_lax/test_linalg.py b/ivy_tests/test_ivy/test_frontends/test_jax/test_lax/test_linalg.py
--- a/ivy_tests/test_ivy/test_frontends/test_jax/test_lax/test_linalg.py
+++ b/ivy_tests/test_ivy/test_frontends/test_jax/test_lax/test_linalg.py
@@ -119,6 +119,45 @@ def test_jax_eigh(
     )
 
 
+# qr
+@handle_frontend_test(
+    fn_tree="jax.lax.linalg.qr",
+    dtype_and_x=helpers.dtype_and_values(
+        available_dtypes=helpers.get_dtypes("float", index=1),
+        min_num_dims=3,
+        max_num_dims=5,
+        min_dim_size=2,
+        max_dim_size=5,
+        min_value=2,
+        max_value=5,
+    ),
+    mode=st.sampled_from((True, False)),
+    test_with_out=st.just(False),
+)
+def test_jax_qr(
+    *,
+    dtype_and_x,
+    mode,
+    on_device,
+    fn_tree,
+    frontend,
+    test_flags,
+    backend_fw,
+):
+    dtype, x = dtype_and_x
+    ret, frontend_ret = helpers.test_frontend_function(
+        input_dtypes=dtype,
+        test_values=False,
+        backend_to_test=backend_fw,
+        frontend=frontend,
+        test_flags=test_flags,
+        fn_tree=fn_tree,
+        on_device=on_device,
+        x=np.asarray(x[0], dtype[0]),
+        full_matrices=mode,
+    )
+
+
 # svd
 @handle_frontend_test(
     fn_tree="jax.lax.linalg.svd",
Repository: ivy-llc/ivy

Issue:
matrix_power



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
@@ -759,6 +759,12 @@ def size(self, dim=None):
     def matmul(self, other):
         return torch_frontend.matmul(self, other)
 
+    @with_supported_dtypes(
+        {"2.0.1 and below": ("float32", "float64", "complex32", "complex64")}, "torch"
+    )
+    def matrix_power(self, n, *, out=None):
+        return torch_frontend.linalg.matrix_power(self, n, out=out)
+
     def argwhere(self):
         return torch_frontend.argwhere(self)
 


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
@@ -9185,6 +9185,43 @@ def test_torch_tensor_matmul(
     )
 
 
+# matrix_power
+@handle_frontend_method(
+    class_tree=CLASS_TREE,
+    init_tree="torch.tensor",
+    method_name="matrix_power",
+    dtype_x=_get_dtype_and_matrix(square=True, invertible=True),
+    n=helpers.ints(min_value=2, max_value=5),
+)
+def test_torch_tensor_matrix_power(
+    dtype_x,
+    n,
+    frontend_method_data,
+    init_flags,
+    method_flags,
+    frontend,
+    on_device,
+    backend_fw,
+):
+    input_dtype, x = dtype_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={
+            "n": n,
+        },
+        frontend_method_data=frontend_method_data,
+        init_flags=init_flags,
+        method_flags=method_flags,
+        frontend=frontend,
+        on_device=on_device,
+    )
+
+
 # max
 @handle_frontend_method(
     class_tree=CLASS_TREE,