class_docstr: Reads `Webdataset` data format, and creates index file
  that enables random access.
  
  Example usage:
  ----------
  >> with IndexCreator('data/test.tar','data/test.idx') as ic:
  >>     ic.create_index()
  >> !ls data/
  test.tar  test.idx
  
  Parameters
  ----------
  uri : str
      Path to the archive file.
  idx_path : str
      Path to the index file, that will be created/overwritten.
class_docstr_tok: ["Reads","`","Webdataset","`","data","format",",","and","creates","index","file","that","enables","random","access",".","Example","usage",":","--","--","--","--","--",">",">","with","IndexCreator","(","'data\/test.tar","'",",","'data\/test.idx","'",")","as","ic",":",">",">","ic.create_index","(",")",">",">","!","ls","data\/","test.tar","test.idx","Parameters","--","--","--","--","--","uri",":","str","Path","to","the","archive","file",".","idx_path",":","str","Path","to","the","index","file",",","that","will","be","created\/overwritten","."]
docstr: Creates the index file from a tar archive
docstr_tok: ["Creates","the","index","file","from","a","tar","archive"]
code: def create_index(self):
      """Creates the index file from a tar archive"""
      self.reset()
  
      pre_time = time.time()
      counter = 0
      report_step = 100000
  
      if self.verbose:
          print(
              f"time: {time.time() - pre_time:.2f} count: {counter} stage: collect"
          )
  
      # Aggregates extensions in samples
      aggregated_data = []
      last_basename = None
  
      for offset, name, size in (
          self._get_data_tar()
          if which("tar") is not None
          else self._get_data_tarfile()
      ):
          if counter % report_step == 0 and counter > 0:
              cur_time = time.time()
              if self.verbose:
                  print(
                      f"time: {cur_time - pre_time:.2f} count: {counter} stage: collect"
                  )
          counter += 1
  
          basename, extension = IndexCreator.split_name(name)
  
          # check for the files starting with a dot (hidden files)
          if not basename or basename.endswith("/"):
              continue
  
          if last_basename != basename:
              aggregated_data.append([(extension, offset, size, name)])
              last_basename = basename
          else:
              aggregated_data[-1].append(
                  (extension, offset, size, name)
              )
  
      if not aggregated_data:
          raise ValueError("Webdataset Tar File empty")
  
      # Constructs the index file out of the aggregated extensions
      self.fidx.write(
          f"{IndexCreator.index_file_version} {len(aggregated_data)}\n"
      )
      for bundle in aggregated_data:
          if counter % report_step == 0:
              cur_time = time.time()
              if self.verbose:
                  print(
                      f"time: {cur_time - pre_time:.2f} count: {counter} stage: index"
                  )
          self.fidx.write(
              " ".join(
                  map(
                      lambda component: " ".join(map(str, component)),
                      bundle,
                  )
              )
          )
          self.fidx.write("\n")
          counter += 1
  
      cur_time = time.time()
      if self.verbose:
          print(
              f"time: {cur_time - pre_time:.2f} count: {counter} stage: done"
          )
  
file_path: DALI/tools/wds2idx.py
imports: import argparse
  import os
  import subprocess
  import sys
  import tarfile
  import time
  from shutil import which
label_desc: Use image node_id 10 for calling the IndexCreator obj's underlying member method code with example usage: obj.create_index() without return types