code: def test_print_all_ivy_arrays_on_dev(
      *,
      num,
      attr_only,
      on_device,
      backend_fw,
  ):
      with BackendHandler.update_backend(backend_fw) as ivy_backend:
          arr = [
              ivy_backend.array(np.random.uniform(size=2))
              for _ in range(num)
          ]
  
          # Flush to avoid artifact
          sys.stdout.flush()
          # temporarily redirect output to a buffer
          captured_output = io.StringIO()
          sys.stdout = captured_output
  
          ivy_backend.print_all_ivy_arrays_on_dev(
              device=on_device, attr_only=attr_only
          )
          # Flush again to make sure all data is printed
          sys.stdout.flush()
          written = captured_output.getvalue().splitlines()
          # restore stdout
          sys.stdout = sys.__stdout__
  
          # Should have written same number of lines as the number of array in device
          assert len(written) == num
  
          if attr_only:
              # Check that the attribute are printed are in the format of
              # (ivy.Shape(dim,...), type)
              regex = r"^\(ivy.Shape\((\d+,(\d,\d*)*)\), \'\w*\'\)$"
          else:
              # Check that the arrays are printed are in the format of ivy.array(...)
              regex = r"^ivy\.array\(\[.*\]\)$"
  
          # Clear the array from device
          for item in arr:
              del item
  
          # Apply the regex search
          assert all(re.match(regex, line) for line in written)
  
imports: import io
  import multiprocessing
  import os
  import re
  import shutil
  import sys
  import warnings
  import numpy
  import psutil
  import subprocess
  from hypothesis import strategies, assume
  import ivy
  import ivy_tests.test_ivy.helpers
  import ivy_tests.test_ivy.helpers.globals
  from ivy_tests.test_ivy.helpers import handle_test, BackendHandler
label_desc: Use image node_id 23 for calling a global function with example usage: test_print_all_ivy_arrays_on_dev() without return types