docstr: Assert memory usage doesn't increase beyond given threshold for f.
docstr_tok: ["Assert","memory","usage","does","n't","increase","beyond","given","threshold","for","f","."]
code: def assertMemoryNotIncreasing(self, f, num_iters, max_increase_mb):
      """Assert memory usage doesn't increase beyond given threshold for f."""
  
      # Warm up.
      f()
      # Wait for background threads to start up and allocate memory.
      time.sleep(4)
      initial = memory_profiler.memory_usage(-1)[0]
      for _ in range(num_iters):
          f()
      increase = memory_profiler.memory_usage(-1)[0] - initial
      logging.info("Memory increase observed: %f MB" % increase)
      assert increase < max_increase_mb, (
          "Increase is too high. Initial memory usage: %f MB. Increase: %f MB. "
          "Maximum allowed increase: %f"
      ) % (initial, increase, max_increase_mb)
  
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 2 for calling the MemoryCleanupTest obj's underlying member method code with example usage: obj.assertMemoryNotIncreasing(f, num_iters, max_increase_mb) without return types