code: def malloc(self, size):
      # print(f"Allocating {size} bytes")
      if size > self.page_size:
          raise ValueError(
              f"Tried allocating {size} but"
              + f" page size is {self.page_size}"
          )
  
      if size > self.space_left_in_page:
          self.flush_page()
          # We book the next available page in the file
          with self.next_page_allocated.get_lock():
              self.my_page = self.next_page_allocated.value
              self.next_page_allocated.value = self.my_page + 1
  
          self.page_offset = 0
          # This is a new page so we erate the content of the buffer
          self.page_data.fill(0)
  
          # We check if we already allocated space for this sample on
          # the page that is now full
          region_in_previous_page = False
          while (
              self.allocations
              and self.allocations[-1][0] == self.current_sample_id
          ):
              # We have to revert the allocations we did and we are giving
              # up on this sample.
              self.allocations.pop()
              # We found at least memory region from the preivous page
              region_in_previous_page = True
  
          # The writer will restart from this freshly allocated page
          if region_in_previous_page:
              raise MemoryError(
                  "Not enough memory to fit the whole sample"
              )
  
      previous_offset = self.page_offset
      self.page_offset += size
  
      buffer = self.page_data[previous_offset : self.page_offset]
      ptr = (
          self.offset + self.my_page * self.page_size + previous_offset
      )
  
      # We return the pointer to the location in file and where to write
      # the data
      self.allocations.append((self.current_sample_id, ptr, size))
      return ptr, buffer
  
file_path: ffcv/ffcv/memory_allocator.py
imports: import numpy
  from time import sleep
  from os import SEEK_END
  from multiprocessing import Value
  from .utils import align_to_page
  import ctypes
label_desc: Use image node_id 5 for calling the MemoryAllocator obj's underlying member method code with example usage: obj.malloc(size) and returns: ptr,  buffer