docstr: Assert consuming elements from the dataset does not leak memory.
docstr_tok: ["Assert","consuming","elements","from","the","dataset","does","not","leak","memory","."]
code: def assertNoMemoryLeak(self, dataset_fn):
      """Assert consuming elements from the dataset does not leak memory."""
  
      def run():
          get_next = self.getNext(dataset_fn())
          for _ in range(100):
              self.evaluate(get_next())
  
      for _ in range(10):
          run()
  
      gc.collect()
  
      def is_native_object(o):
          # First check if `o` is a weakref proxy. Calling
          # `isinstance(o, internal.NativeObject)` on an expired weak reference
          # proxy will raise a ReferenceError.
          if isinstance(o, weakref.ProxyTypes):
              return False
          return isinstance(o, internal.NativeObject)
  
      tensors = [o for o in gc.get_objects() if is_native_object(o)]
      self.assertEmpty(
          tensors, "%d Tensors are still alive." % len(tensors)
      )
  
imports: import gc
  import time
  import weakref
  from absl.testing import parameterized
  from tensorflow.python.data.kernel_tests import test_base
  from tensorflow.python.data.ops import dataset_ops
  from tensorflow.python.data.ops import multi_device_iterator_ops
  from tensorflow.python.framework import combinations
  from tensorflow.python.framework import dtypes
  from tensorflow.python.platform import test
  from tensorflow.python.platform import tf_logging
  from tensorflow.python.types import internal
label_desc: Use image node_id 3 for calling the MemoryCleanupTest obj's underlying member method code with example usage: obj.assertNoMemoryLeak(dataset_fn) and returns: isinstance, False