class_docstr: Object class to write the index (.idx) file
  
  Args:
      idx_path (str): The path to the index file
  
      dtype (Type[numpy.number]): The dtype of the index file
class_docstr_tok: ["Object","class","to","write","the","index","(",".idx",")","file","Args",":","idx_path","(","str",")",":","The","path","to","the","index","file","dtype","(","Type","[","numpy.number","]",")",":","The","dtype","of","the","index","file"]
docstr: Write the index (.idx) file
  
  Args:
      sequence_lengths (List[int]): The length of each sequence
  
      sequence_modes (Optional[List[int]]): The mode of each sequences
  
      document_indices (List[int]): The seqyebce indices demarcating the end of each document
docstr_tok: ["Write","the","index","(",".idx",")","file","Args",":","sequence_lengths","(","List","[","int","]",")",":","The","length","of","each","sequence","sequence_modes","(","Optional","[","List","[","int","]","]",")",":","The","mode","of","each","sequences","document_indices","(","List","[","int","]",")",":","The","seqyebce","indices","demarcating","the","end","of","each","document"]
code: def write(
      self,
      sequence_lengths: List[int],
      sequence_modes: Optional[List[int]],
      document_indices: List[int],
  ) -> None:
      """Write the index (.idx) file
  
      Args:
          sequence_lengths (List[int]): The length of each sequence
  
          sequence_modes (Optional[List[int]]): The mode of each sequences
  
          document_indices (List[int]): The seqyebce indices demarcating the end of each document
      """
      sequence_pointers = self._sequence_pointers(sequence_lengths)
  
      # the number of sequences in the dataset
      sequence_count = len(sequence_lengths)
      self.idx_writer.write(struct.pack("<Q", sequence_count))
  
      # the number of documents in the dataset
      document_count = len(document_indices)
      self.idx_writer.write(struct.pack("<Q", document_count))
  
      # the number of tokens per sequence
      sequence_lengths = numpy.array(
          sequence_lengths, dtype=numpy.int32
      )
      self.idx_writer.write(sequence_lengths.tobytes(order="C"))
      del sequence_lengths
  
      # the byte offsets for all sequences
      sequence_pointers = numpy.array(
          sequence_pointers, dtype=numpy.int64
      )
      self.idx_writer.write(sequence_pointers.tobytes(order="C"))
      del sequence_pointers
  
      # the sequence indices marking the end of each document
      document_indices = numpy.array(
          document_indices, dtype=numpy.int64
      )
      self.idx_writer.write(document_indices.tobytes(order="C"))
  
      # the mode per sequence
      if sequence_modes is not None:
          sequence_modes = numpy.array(sequence_modes, dtype=numpy.int8)
          self.idx_writer.write(sequence_modes.tobytes(order="C"))
          del sequence_modes
  
imports: import logging
  import os
  import shutil
  import struct
  import time
  from enum import Enum
  from functools import lru_cache
  from itertools import accumulate
  from types import TracebackType
  from typing import List, Optional, Tuple, Type, Union
  import numpy
  import torch
  from megatron.core.datasets.utils import log_single_rank
label_desc: Use image node_id 4 for calling the _IndexWriter obj's underlying member method code with example usage: obj.write(sequence_lengths, sequence_modes, document_indices) without return types