code: def test_default_device(backend_fw):
      with BackendHandler.update_backend(backend_fw) as ivy_backend:
          # setting and unsetting
          orig_len = len(ivy_backend.default_device_stack)
          ivy_backend.set_default_device("cpu")
          assert len(ivy_backend.default_device_stack) == orig_len + 1
          ivy_backend.set_default_device("cpu")
          assert len(ivy_backend.default_device_stack) == orig_len + 2
          ivy_backend.unset_default_device()
          assert len(ivy_backend.default_device_stack) == orig_len + 1
          ivy_backend.unset_default_device()
          assert len(ivy_backend.default_device_stack) == orig_len
  
          # with
          assert len(ivy_backend.default_device_stack) == orig_len
          with ivy_backend.DefaultDevice("cpu"):
              assert (
                  len(ivy_backend.default_device_stack) == orig_len + 1
              )
              with ivy_backend.DefaultDevice("cpu"):
                  assert (
                      len(ivy_backend.default_device_stack)
                      == orig_len + 2
                  )
              assert (
                  len(ivy_backend.default_device_stack) == orig_len + 1
              )
          assert len(ivy_backend.default_device_stack) == orig_len
  
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 12 for calling a global function with example usage: test_default_device(backend_fw) without return types