code: def _check_handle(self, func):
      handles = [func(), None, None]
  
      def _subthread():
          cupy.cuda.Device().use()
          handles[1] = func()
          handles[2] = func()
  
      t = threading.Thread(target=_subthread)
      t.start()
      t.join()
      assert handles[0] is not None
      assert handles[0] != handles[1]
      assert handles[1] == handles[2]
  
imports: import re
  import threading
  import unittest
  import pytest
  import cupy
  from cupy import cuda
  from cupy import testing
label_desc: Use image node_id 1 for calling the TestDeviceHandles obj's underlying member method code with example usage: obj._check_handle(func) without return types