code: def finalize(self, index_file):
      self.out_file.close()
      index = open(index_file, "wb")
      index.write(b"TNTIDX\x00\x00")
      index.write(struct.pack("<Q", 1))
      index.write(
          struct.pack("<QQ", code(self.dtype), self.element_size)
      )
      index.write(
          struct.pack(
              "<QQ", len(self.data_offsets) - 1, len(self.sizes)
          )
      )
      index.write(struct.pack("<Q", len(self.doc_idx)))
      write_longs(index, self.dim_offsets)
      write_longs(index, self.data_offsets)
      write_longs(index, self.sizes)
      write_longs(index, self.doc_idx)
      index.close()
  
imports: import os
  import shutil
  import struct
  from functools import lru_cache
  from itertools import accumulate
  import numpy
  import torch
label_desc: Use image node_id 5 for calling the IndexedDatasetBuilder obj's underlying member method code with example usage: obj.finalize(index_file) without return types