code: def test_device():
      device_list = []
      device_list.append(device.current_device())
  
      def f():
          set_default_device(mx.gpu(11))
          device_list.append(device.current_device())
  
      thread = threading.Thread(target=f)
      thread.start()
      thread.join()
      assert Device.devtype2str[device_list[0].device_typeid] == "cpu"
      assert device_list[0].device_id == 0
      assert Device.devtype2str[device_list[1].device_typeid] == "gpu"
      assert device_list[1].device_id == 11
  
      e1 = threading.Event()
      e2 = threading.Event()
      status = [False]
  
      def g():
          with mx.cpu(10):
              e2.set()
              e1.wait()
              if device.current_device().device_id == 10:
                  status[0] = True
  
      thread = threading.Thread(target=g)
      thread.start()
      e2.wait()
      with Device("cpu", 11):
          e1.set()
          thread.join()
      e1.clear()
      e2.clear()
      assert status[0], "Spawned thread didn't set the correct device"
  
file_path: mxnet/tests/python/unittest/test_thread_local.py
imports: import threading
  import numpy
  import mxnet
  from mxnet import device, attribute
  from mxnet.device import Device
  from mxnet.attribute import AttrScope
  from mxnet.test_utils import assert_almost_equal, set_default_device
  from mxnet.util import _NumpyArrayScope, set_np_shape
label_desc: Use image node_id 1 for calling a global function with example usage: test_device() without return types