code: def flush_page(self):
      # If we haven't allocated any page we end there
      if self.my_page < 0:
          return
  
      # We shouldn't have allocated a page and have nothing to write on it
      assert self.page_offset != 0
      # Wait until it's my turn to write
      while self.next_page_written.value != self.my_page:
          # Essentially a spin lock
          # TODO we could replace it with like exponential backoff
          sleep(0.001)
          pass
  
      # Now it's my turn to write
  
      expected_file_offset = self.offset + self.my_page * self.page_size
      # in order to be aligned with page size
      # If this is the first page we have to pad with zeros
      if self.my_page == 0:
          # print("Padding headers to align with page size")
          current_location = self.fp.seek(0, SEEK_END)
          null_bytes_to_write = expected_file_offset - current_location
          self.fp.write(
              np.zeros(null_bytes_to_write, dtype="<u1").tobytes()
          )
          # print(f"current file pointer is no {self.fp.tell()} and should be {expected_file_offset}")
  
      self.fp.seek(expected_file_offset)
  
      # print(f"Writing page {self.my_page} at offset {self.fp.tell()}")
      self.fp.write(self.page_data.tobytes())
      # print(f"Done writing {self.my_page} at offset {self.fp.tell()}")
  
      # We warn other processes that they are free to write the next page
      with self.next_page_written.get_lock():
          self.next_page_written.value += 1
  
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 6 for calling the MemoryAllocator obj's underlying member method code with example usage: obj.flush_page() without return types