class_docstr: Dataset containing sentences and their blocks for an inverse cloze task.
class_docstr_tok: ["Dataset","containing","sentences","and","their","blocks","for","an","inverse","cloze","task","."]
docstr: Get an ICT example of a pseudo-query and the block of text from which it was extracted
docstr_tok: ["Get","an","ICT","example","of","a","pseudo-query","and","the","block","of","text","from","which","it","was","extracted"]
code: def __getitem__(self, idx):
      """Get an ICT example of a pseudo-query and the block of text from which it was extracted"""
      sample_data = self.samples_mapping[idx]
      start_idx, end_idx, doc_idx, block_idx = sample_data.as_tuple()
  
      if self.use_titles:
          title = self.title_dataset[int(doc_idx)]
          title_pad_offset = 3 + len(title)
      else:
          title = None
          title_pad_offset = 2
      block = [self.block_dataset[i] for i in range(start_idx, end_idx)]
      assert (
          len(block) > 1
          or self.use_one_sent_docs
          or self.query_in_block_prob == 1
      )
  
      # randint() is inclusive for Python rng
      rand_sent_idx = self.rng.randint(0, len(block) - 1)
  
      # keep the query in the context query_in_block_prob fraction of the time.
      if self.rng.random() < self.query_in_block_prob:
          query = block[rand_sent_idx].copy()
      else:
          query = block.pop(rand_sent_idx)
  
      # still need to truncate because blocks are concluded when
      # the sentence lengths have exceeded max_seq_length.
      query = query[: self.max_seq_length - 2]
      block = list(itertools.chain(*block))[
          : self.max_seq_length - title_pad_offset
      ]
  
      query_tokens, query_pad_mask = self.concat_and_pad_tokens(query)
      context_tokens, context_pad_mask = self.concat_and_pad_tokens(
          block, title
      )
  
      query_mask = make_attention_mask(query_tokens, query_tokens)
      context_mask = make_attention_mask(context_tokens, context_tokens)
  
      block_data = sample_data.as_array()
  
      sample = {
          "query_tokens": query_tokens,
          "query_mask": query_mask,
          "query_pad_mask": query_pad_mask,
          "context_tokens": context_tokens,
          "context_mask": context_mask,
          "context_pad_mask": context_pad_mask,
          "block_data": block_data,
      }
  
      return sample
  
file_path: ColossalAI/examples/tutorial/sequence_parallel/data/datasets/ict_dataset.py
imports: import itertools
  import random
  import numpy
  from megatron import get_args, get_tokenizer
  from megatron.data.dataset_utils import get_indexed_dataset_
  from megatron.data.realm_dataset_utils import get_block_samples_mapping
  from torch.utils.data import Dataset
label_desc: Use image node_id 3 for calling the ICTDataset obj's underlying member method code with example usage: obj.__getitem__(idx) and returns: sample