code: def print_objects():
      # gc.collect()
      tensors = [x for x in gc.get_objects() if isinstance(x, Tensor)]
      tensor_ram_used = sum([prod(x.shape) * 4 for x in tensors])
      lazybuffers = [
          x for x in gc.get_objects() if isinstance(x, LazyBuffer)
      ]
      gpubuffers = [
          x for x in gc.get_objects() if isinstance(x, Buffer)
      ]
      realized_buffers = [
          x.realized for x in lazybuffers if x.base == x and x.realized
      ]
      gpubuffers_orphaned = [
          x for x in gpubuffers if x not in realized_buffers
      ]
  
      print(
          f"{len(tensors)} tensors allocated in {tensor_ram_used/1e9:.2f} GB, GPU using {GlobalCounters.mem_used/1e9:.2f} GB"
      )
      print(
          f"{len(lazybuffers)} lazybuffers {len(realized_buffers)} realized, {len(gpubuffers)} GPU buffers"
      )
      print(f"{len(gpubuffers_orphaned)} GPU buffers are orphaned")
  
      cnt = 0
      for tb in gpubuffers_orphaned:
          bb = gc.get_referrers(tb)
          for b in bb:
              if b is not gpubuffers and b is not gpubuffers_orphaned:
                  print(
                      tb, "\nreference", type(b), len(b), str(b)[0:150]
                  )
                  for x in gc.get_referrers(b):
                      print("double reference", str(x)[0:100])
                  print("\n")
          if cnt == 10:
              break
          cnt += 1
  
      for x in gpubuffers_orphaned:
          if getattr(x, "_buf", None):
              del x._buf
          if getattr(x, "_image", None):
              del x._image
  
      return len(gpubuffers_orphaned)
  
imports: import gc
  from tinygrad.helpers import prod
  from tinygrad.tensor import Tensor
  from tinygrad.lazy import LazyBuffer
  from tinygrad.device import Buffer
  from tinygrad import GlobalCounters
label_desc: Use image node_id 1 for calling a global function with example usage: print_objects() and returns: len