code: def testFromGeneratorDestructorCalled(self):
      # Use an `Event` to signal that the generator has been deleted.
      event = threading.Event()
  
      class GeneratorWrapper:
          def __iter__(self):
              return self
  
          def next(self):
              return self.__next__()
  
          def __next__(self):
              return 42
  
          def __del__(self):
              event.set()
  
      dataset = dataset_ops.Dataset.from_generator(
          GeneratorWrapper, output_types=dtypes.int64
      ).take(2)
      get_next = self.getNext(dataset)
  
      self.assertAllEqual(42, self.evaluate(get_next()))
      self.assertAllEqual(42, self.evaluate(get_next()))
      with self.assertRaises(errors.OutOfRangeError):
          self.evaluate(get_next())
      # Test that `GeneratorWrapper` object is destroyed when the
      # iterator terminates (and the generator iterator is deleted).
      self.assertTrue(event.is_set())
  
imports: import threading
  from absl.testing import parameterized
  import numpy
  from tensorflow.python.data.kernel_tests import test_base
  from tensorflow.python.data.ops import dataset_ops
  from tensorflow.python.data.ops import from_generator_op
  from tensorflow.python.framework import combinations
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import sparse_tensor
  from tensorflow.python.framework import tensor_spec
  from tensorflow.python.ops import script_ops
  from tensorflow.python.ops import sparse_ops
  from tensorflow.python.ops.ragged import ragged_factory_ops
  from tensorflow.python.ops.ragged import ragged_tensor
  from tensorflow.python.platform import test
label_desc: Use image node_id 16 for calling the FromGeneratorTest obj's underlying member method code with example usage: obj.testFromGeneratorDestructorCalled() and returns: self, self, int