Repository: ivy-llc/ivy
Pull request: change from is_native_array to is_ivy array in get_all_arrays_in_memory
This fixes #10428

Problem statement:
[Bug]: ivy.get_all_arrays_in_memory() produces errors
### Bug Explanation

when using get_all_arrays_in_memory function gives below error
numpy: is_native_array: maximum recursion depth exceeded in comparison 
It should return ivy.Array but it returns garbage value

### Steps to Reproduce Bug

ex:- get_all_arrays_in_memory() in python console 

### Environment

ArchLinux ,venv environment

### Ivy Version

v1.1.9

### Backend

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

### Device

CPU

Hints from issue discussion:

Commit message: add ivy array instead of native array when current backend is default or numpy

Patch to review:
diff --git a/ivy/functional/ivy/general.py b/ivy/functional/ivy/general.py
index afd19cc87d133..d2aeb68e1949a 100644
--- a/ivy/functional/ivy/general.py
+++ b/ivy/functional/ivy/general.py
@@ -2177,13 +2177,18 @@ def stable_pow(
 
 
 @handle_exceptions
-def get_all_arrays_in_memory():
+def get_all_arrays_in_memory() -> ivy.Array:
     """Gets all arrays which are currently alive."""
     all_arrays = list()
     for obj in gc.get_objects():
         try:
-            if ivy.is_native_array(obj):
-                all_arrays.append(obj)
+            if ivy.current_backend_str() in ["", "numpy"]:
+                if ivy.is_ivy_array(obj):
+                    all_arrays.append(obj)
+            else:
+                if ivy.is_native_array(obj):
+                    all_arrays.append(obj)
+
         except Exception:
             pass
     return all_arrays


Code review comments:
diff_hunk: @@ -2177,13 +2177,18 @@ def stable_pow(
 
 
 @handle_exceptions
-def get_all_arrays_in_memory():
+def get_all_arrays_in_memory() -> ivy.Array:
path: ivy/functional/ivy/general.py
text: @user1:
This function returns a list of arrays
```suggestion
def get_all_arrays_in_memory() -> List[ivy.Array, ivy.NativeArray]:
```

@author:
My bad
 i will fix the code and push it tomorrow