class_docstr: Pretraining chunk dataset wraps a standard GPT dataset.
  
  This dataset conceptually divides each sample (e.g., length 2048)
  into chunks (e.g., length 64) and restructures them into a list of
  chunks (e.g., length num_samples * num_chunks_per_sample).
class_docstr_tok: ["Pretraining","chunk","dataset","wraps","a","standard","GPT","dataset",".","This","dataset","conceptually","divides","each","sample","(","e.g.",",","length","2048",")","into","chunks","(","e.g.",",","length","64",")","and","restructures","them","into","a","list","of","chunks","(","e.g.",",","length","num_samples","*","num_chunks_per_sample",")","."]
code: def __getitem__(self, idx):
      # Convert global chunk index to global sample index & local chunk index.
      sample_idx = idx // self.n_chunks_per_sample
      chunk_idx = idx % self.n_chunks_per_sample
  
      # Extract sample data.
      sample = self.sample_dataset[sample_idx]
      sample_token_ids = sample["text"]
      sample_doc_ids = sample["document_ids"]
  
      # Chunk start/end token idxs.
      token_start_idx = chunk_idx * self.chunk_length
      token_end_idx = token_start_idx + self.chunk_length
      chunk_token_ids = sample_token_ids[token_start_idx:token_end_idx]
  
      # Sample.
      return {
          "doc_ids": sample_doc_ids,
          "text": chunk_token_ids,
      }
  
file_path: megatron-lm/tools/retro/query/chunk_dataset.py
imports: import os
  import torch
  from megatron import get_args, get_retro_args, print_rank_0
  from megatron.core.datasets.blended_megatron_dataset_builder import BlendedMegatronDatasetBuilder
  from megatron.training import build_train_valid_test_datasets, update_train_iters
  from pretrain_gpt import is_dataset_built_on_rank
  from tools.retro.db.utils import get_indexed_dataset_infos
  from tools.retro.utils import get_num_chunks_per_sample
  from .multi_split_gpt_dataset import MultiSplitGPTDataset, MultiSplitGPTDatasetConfig
  from .utils import get_neighbor_dirname, get_query_workdir
label_desc: Use image node_id 3 for calling the ChunkDataset obj's underlying member method code with example usage: obj.__getitem__(idx) and returns: dict