Repository: ivy-llc/ivy

Issue:
Fix Ivy Failing Test: torch - general.get_item
ToDo - #27501
Sub-Task: Priority Open


Discussion:

Resolving patch:
diff --git a/ivy/functional/backends/jax/general.py b/ivy/functional/backends/jax/general.py
--- a/ivy/functional/backends/jax/general.py
+++ b/ivy/functional/backends/jax/general.py
@@ -1,25 +1,26 @@
 """Collection of Jax general functions, wrapped to fit Ivy syntax and
 signature."""
 
-# global
-import jax
-import numpy as np
-import jax.numpy as jnp
+import importlib
+import multiprocessing as _multiprocessing
+from functools import reduce as _reduce
 from numbers import Number
 from operator import mul
-from functools import reduce as _reduce
-from typing import Optional, Union, Sequence, Callable, Tuple
-import multiprocessing as _multiprocessing
-import importlib
+from typing import Callable, Optional, Sequence, Tuple, Union
 
+# global
+import jax
+import jax.numpy as jnp
+import numpy as np
 
 # local
 import ivy
 from ivy.func_wrapper import with_unsupported_dtypes
+from ivy.functional.backends.jax import JaxArray, NativeArray
 from ivy.functional.backends.jax.device import _to_array, _to_device
 from ivy.functional.ivy.general import _broadcast_to
-from ivy.functional.backends.jax import JaxArray, NativeArray
 from ivy.utils.exceptions import _check_inplace_update_support
+
 from . import backend_version
 
 
@@ -68,6 +69,8 @@ def get_item(
     *,
     copy: Optional[bool] = None,
 ) -> JaxArray:
+    if copy:
+        x = x.copy()
     if ivy.is_array(query) and ivy.is_bool_dtype(query):
         if not len(query.shape):
             if not query:
diff --git a/ivy/functional/backends/numpy/general.py b/ivy/functional/backends/numpy/general.py
--- a/ivy/functional/backends/numpy/general.py
+++ b/ivy/functional/backends/numpy/general.py
@@ -1,20 +1,23 @@
 """Collection of Numpy general functions, wrapped to fit Ivy syntax and
 signature."""
 
-# global
-from typing import Optional, Union, Sequence, Callable, Tuple
-import numpy as np
-from operator import mul
-from functools import reduce as _reduce
 import multiprocessing as _multiprocessing
+from functools import reduce as _reduce
 from numbers import Number
+from operator import mul
+
+# global
+from typing import Callable, Optional, Sequence, Tuple, Union
+
+import numpy as np
 
 # local
 import ivy
-from ivy.functional.backends.numpy.helpers import _scalar_output_to_0d_array
 from ivy.func_wrapper import with_unsupported_dtypes
-from . import backend_version
+from ivy.functional.backends.numpy.helpers import _scalar_output_to_0d_array
+
 from ...ivy.general import _broadcast_to
+from . import backend_version
 
 
 def array_equal(x0: np.ndarray, x1: np.ndarray, /) -> bool:
@@ -37,6 +40,8 @@ def get_item(
     *,
     copy: Optional[bool] = None,
 ) -> np.ndarray:
+    if copy:
+        x = x.copy()
     return x.__getitem__(query)
 
 
diff --git a/ivy/functional/backends/torch/general.py b/ivy/functional/backends/torch/general.py
--- a/ivy/functional/backends/torch/general.py
+++ b/ivy/functional/backends/torch/general.py
@@ -5,7 +5,7 @@
 from functools import reduce as _reduce
 from numbers import Number
 from operator import mul
-from typing import Optional, Union, Sequence, Callable, List, Tuple
+from typing import Callable, List, Optional, Sequence, Tuple, Union
 
 try:
     import functorch
@@ -16,9 +16,10 @@
 
 # local
 import ivy
-from ivy.func_wrapper import with_unsupported_dtypes, _update_torch_views
-from . import backend_version, is_variable
+from ivy.func_wrapper import _update_torch_views, with_unsupported_dtypes
+
 from ...ivy.general import _broadcast_to
+from . import backend_version, is_variable
 
 torch_scatter = None
 
@@ -94,6 +95,8 @@ def get_item(
     *,
     copy: Optional[bool] = None,
 ) -> torch.Tensor:
+    if copy:
+        x = x.clone()
     return x.__getitem__(query)
 
 


Test patch: