code: def cache_restore_device(request):
      device = chainerx.get_default_device()
  
      def restore_device():
          chainerx.set_default_device(device)
  
      request.addfinalizer(restore_device)
  
file_path: chainer/tests/chainerx_tests/unit_tests/test_device.py
imports: import copy
  import pickle
  import pytest
  import chainerx
label_desc: Use image node_id 5 for calling a global function with example usage: cache_restore_device(request) without return types