code: def testRoundTrip(self, dtype, shape):
      np.random.seed(42)
      np_array = np.random.randint(0, 10, shape)
      # copy to gpu if available
      tf_tensor = array_ops.identity(
          constant_op.constant(np_array, dtype=dtype)
      )
      tf_tensor_device = tf_tensor.device
      tf_tensor_dtype = tf_tensor.dtype
      dlcapsule = dlpack.to_dlpack(tf_tensor)
      del tf_tensor  # should still work
      tf_tensor2 = dlpack.from_dlpack(dlcapsule)
      self.assertAllClose(np_array, tf_tensor2)
      if tf_tensor_dtype == dtypes.int32:
          # int32 tensor is always on cpu for now
          self.assertEqual(
              tf_tensor2.device,
              "/job:localhost/replica:0/task:0/device:CPU:0",
          )
      else:
          self.assertEqual(tf_tensor_device, tf_tensor2.device)
  
file_path: tensorflow-upstream/tensorflow/python/dlpack/dlpack_test.py
imports: from absl.testing import parameterized
  import numpy
  from tensorflow.python.dlpack import dlpack
  from tensorflow.python.eager import context
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import ops
  from tensorflow.python.platform import test
  from tensorflow.python.ops import array_ops
label_desc: Use image node_id 1 for calling the DLPackTest obj's underlying member method code with example usage: obj.testRoundTrip(dtype, shape) without return types