code: def Sample(self):
      
      self._profiling_sample += 1
  
      if self._profiling_sample >= self._profiling_sample_rate:
        if self._heapy:
          heap = self._heapy.heap()
          heap.dump(self._sample_file)
  
        self._profiling_sample = 0
docs: Takes a sample for profiling.