code: def testTensorsCanBeConsumedOnceOnly(self):
      np.random.seed(42)
      np_array = np.random.randint(0, 10, (2, 3, 4))
      tf_tensor = constant_op.constant(np_array, dtype=np.float32)
      dlcapsule = dlpack.to_dlpack(tf_tensor)
      del tf_tensor  # should still work
      _ = dlpack.from_dlpack(dlcapsule)
  
      def ConsumeDLPackTensor():
          dlpack.from_dlpack(
              dlcapsule
          )  # Should can be consumed only once
  
      self.assertRaisesRegex(
          Exception,
          ".*a DLPack tensor may be consumed at most once.*",
          ConsumeDLPackTensor,
      )
  
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 2 for calling the DLPackTest obj's underlying member method code with example usage: obj.testTensorsCanBeConsumedOnceOnly() without return types