code: def gpu_mem_leave_free_mbs(n):
      """
      Consume whatever memory is needed so that n MBs are left free on the current device.
  
      On success it returns a variable that holds the allocated memory, which
      needs to be kept alive as long as it's needed to hold that memory. Call
      `del` to release the memory when it is no longer needed.
  
      This function is very useful if the test needs to hit OOM, so this function
      will leave just the requested amount of GPU RAM free, regardless of GPU
      utilization or size of the card.
  
      """
      avail = gpu_mem_get_free_mbs()
      assert (
          avail > n
      ), f"already have less available mem than desired {n}MBs"
      consume = avail - n
      # print(f"consuming {consume}MB to bring free mem to {n}MBs")
      buf = gpu_mem_allocate_mbs(consume)
      assert buf is not None, f"failed to allocate {consume}MB"
      return buf
  
file_path: ipyexperiments/ipyexperiments/utils/mem.py
imports: import gc
  import os
  from collections import namedtuple
  from ipyexperiments.utils.pynvml_gate import load_pynvml_env
label_desc: Use image node_id 11 for calling a global function with example usage: gpu_mem_leave_free_mbs(n) and returns: buf