code: def build_db():
      """Extract token chunks from each indexed dataset.
  
      Iterate each document of each indexed dataset, extract that document's
      chunks, and save to a 'DB' (hdf5 file).
      """
  
      # Indexed dataset info.
      indexed_dataset_infos = init_indexed_dataset_infos()
  
      # Build dbs.
      build_individual_dbs(indexed_dataset_infos)
  
      # Single-process going forward.
      if torch.distributed.get_rank() != 0:
          return
  
      # Update n_chunks & save indexed dataset infos.
      if not os.path.exists(get_indexed_dataset_infos_path()):
          update_chunk_counts(indexed_dataset_infos)
          save_indexed_dataset_infos(indexed_dataset_infos)
      indexed_dataset_infos = get_indexed_dataset_infos()
  
      # Merge dbs.
      merge_dbs(indexed_dataset_infos, "sampled")
      merge_dbs(indexed_dataset_infos, "train")
      merge_dbs(indexed_dataset_infos, "valid")
  
imports: from collections import defaultdict
  from concurrent.futures import as_completed, ProcessPoolExecutor
  from functools import reduce
  import glob
  import json
  import numpy
  import os
  from pathlib import Path
  import threading
  import torch
  from tqdm import tqdm
  import types
  from megatron import get_retro_args, print_rank_0
  from megatron.core.datasets.indexed_dataset import MMapIndexedDataset
  from megatron.tokenizer.tokenizer import _BertWordPieceTokenizer, _GPT2BPETokenizer
  from tools.bert_embedding.utils import get_missing_blocks_by_rank
  from tools.retro.external_libs import h5py
  from tools.retro.utils import get_gpt_tokenizer, get_bert_tokenizer
  from .utils import get_indexed_dataset_infos, get_indexed_dataset_infos_path, get_individual_db_dir, get_individual_chunk_db, get_individual_doc_offsets, get_merged_dataset, get_merged_db_path_map, save_indexed_dataset_infos
label_desc: Use image node_id 7 for calling a global function with example usage: build_db() without return types