code: def allocate(self, size):
      from traceback import extract_stack
  
      stack = tuple(frm[2] for frm in extract_stack())
      description = self.describe(stack, size)
  
      histogram = {}
      for bsize, descr in self.blocks.values():
          histogram[bsize, descr] = histogram.get((bsize, descr), 0) + 1
  
      from pytools import common_prefix
  
      cpfx = common_prefix(descr for bsize, descr in histogram)
  
      print(
          "\n  Allocation of size %d occurring "
          "(mem: last_free:%d, free: %d, total:%d) (pool: held:%d, active:%d):"
          "\n      at: %s"
          % (
              (size, self.last_free)
              + cuda.mem_get_info()
              + (self.held_blocks, self.active_blocks, description)
          ),
          file=self.logfile,
      )
  
      hist_items = sorted(histogram.items())
      for (bsize, descr), count in hist_items:
          print(
              "  %s (%d bytes): %dx"
              % (descr[len(cpfx) :], bsize, count),
              file=self.logfile,
          )
  
      if self.interactive:
          input("  [Enter]")
  
      result = DeviceMemoryPool.allocate(self, size)
      self.blocks[result] = size, description
      self.last_free, _ = cuda.mem_get_info()
      return result
  
imports: import pycuda.driver
  import pycuda._driver
  import numpy
  from pycuda.compyte.dtypes import register_dtype, get_or_register_dtype, _fill_dtype_registry, dtype_to_ctype
label_desc: Use image node_id 2 for calling the DebugMemoryPool obj's underlying member method code with example usage: obj.allocate(size) and returns: result