code: def cache_restore_context(request):
      device = chainerx.get_default_device()
      context = chainerx.get_default_context()
      global_context = chainerx.get_global_default_context()
  
      def restore_context():
          chainerx.set_global_default_context(global_context)
          chainerx.set_default_context(context)
          chainerx.set_default_device(device)
  
      request.addfinalizer(restore_context)
  
file_path: chainer/tests/chainerx_tests/unit_tests/test_context.py
imports: import pytest
  import chainerx
label_desc: Use image node_id 1 for calling a global function with example usage: cache_restore_context(request) without return types