class_docstr: Writes given dataset into FFCV format (.beton).
  Supports indexable objects (e.g., PyTorch Datasets) and webdataset.
  
  Parameters
  ----------
  fname: str
      File name to store dataset in FFCV format (.beton)
  fields : Mapping[str, Field]
      Map from keys to Field's (order matters!)
  page_size : int
      Page size used internally
  num_workers : int
      Number of processes to use
code: def finalize(self, allocations):
      # Writing metadata
      with open(self.fname, "r+b") as fp:
          fp.seek(self.metadata_start)
          fp.write(self.metadata_sm.buf)
  
          # We go at the end of the file
          fp.seek(0, SEEK_END)
  
          # Look at the current address
          allocation_table_location = fp.tell()
          # Retrieve all the allocations from the workers
          # Turn them into a numpy array
          try:
              allocation_table = np.array(
                  [
                      np.array(x, dtype=ALLOC_TABLE_TYPE)
                      for x in allocations
                      if len(x)
                  ]
              )
          except:
              allocation_table = np.array([]).view(ALLOC_TABLE_TYPE)
          fp.write(allocation_table.tobytes())
  
          self.header["alloc_table_ptr"] = allocation_table_location
          # We go at the start of the file
          fp.seek(0)
          # And write the header
          fp.write(self.header.tobytes())
  
imports: from functools import partial
  from typing import Callable, List, Mapping
  from os import SEEK_END, path
  import numpy
  from time import sleep
  import ctypes
  from multiprocessing import shared_memory, cpu_count, Queue, Process, Value
  from tqdm import tqdm
  from tqdm.contrib.concurrent import thread_map
  from .utils import chunks, is_power_of_2
  from .fields.base import Field
  from .memory_allocator import MemoryAllocator
  from .types import TYPE_ID_HANDLER, get_metadata_type, HeaderType, FieldDescType, CURRENT_VERSION, ALLOC_TABLE_TYPE
label_desc: Use image node_id 6 for calling the DatasetWriter obj's underlying member method code with example usage: obj.finalize(allocations) without return types