code: def build_training_sample(
      sample,
      target_seq_length,
      max_seq_length,
      max_seq_length_dec,
      vocab_id_list,
      vocab_id_to_token_dict,
      cls_id,
      sep_id,
      mask_id,
      pad_id,
      masked_lm_prob,
      np_rng,
      bos_id=None,
      eos_id=None,
      sentinel_tokens=None,
  ):
      """Build training sample.
  
      Arguments:
          sample: A list of sentences in which each sentence is a list token ids.
          target_seq_length: Desired sequence length.
          max_seq_length: Maximum length of the sequence. All values are padded to
              this length.
          vocab_id_list: List of vocabulary ids. Used to pick a random id.
          vocab_id_to_token_dict: A dictionary from vocab ids to text tokens.
          cls_id: Start of example id.
          sep_id: Separator id.
          mask_id: Mask token id.
          pad_id: Padding token id.
          masked_lm_prob: Probability to mask tokens.
          np_rng: Random number genenrator. Note that this rng state should be
                numpy and not python since python randint is inclusive for
                the opper bound whereas the numpy one is exclusive.
          bos_id: start of decoder example id
          eos_id: end of generation id
          sentinel_tokens: unique value to be substituted for every replaced span
      """
  
      assert target_seq_length <= max_seq_length
  
      # flatten sentences into one list
      tokens = [token for sentence in sample for token in sentence]
  
      # Truncate to `target_sequence_length`.
      max_num_tokens = target_seq_length
      truncated = len(tokens) > max_num_tokens
      tokens = tokens[:max_num_tokens]
  
      # Masking.
      max_predictions_per_seq = masked_lm_prob * max_num_tokens
      (
          tokens,
          masked_positions,
          masked_labels,
          _,
          masked_spans,
      ) = create_masked_lm_predictions(
          tokens,
          vocab_id_list,
          vocab_id_to_token_dict,
          masked_lm_prob,
          cls_id,
          sep_id,
          mask_id,
          max_predictions_per_seq,
          np_rng,
          max_ngrams=10,
          geometric_dist=True,
          masking_style="t5",
      )
  
      # Padding.
      (
          tokens_enc,
          tokens_dec_in,
          labels,
          enc_mask,
          dec_mask,
          enc_dec_mask,
          loss_mask,
      ) = pad_and_convert_to_numpy(
          tokens,
          masked_positions,
          masked_labels,
          pad_id,
          max_seq_length,
          max_seq_length_dec,
          masked_spans,
          bos_id,
          eos_id,
          sentinel_tokens,
      )
  
      train_sample = {
          "text_enc": tokens_enc,
          "text_dec": tokens_dec_in,
          "labels": labels,
          "loss_mask": loss_mask,
          "truncated": int(truncated),
          "enc_mask": enc_mask,
          "dec_mask": dec_mask,
          "enc_dec_mask": enc_dec_mask,
      }
      return train_sample
  
file_path: megatron-lm/megatron/data/t5_dataset.py
imports: import collections
  import numpy
  import torch
  from megatron import get_tokenizer
  from megatron.data.dataset_utils import create_masked_lm_predictions, get_samples_mapping
label_desc: Use image node_id 1 for calling a global function with example usage: build_training_sample(sample, target_seq_length, max_seq_length, max_seq_length_dec, vocab_id_list, vocab_id_to_token_dict, cls_id, sep_id, mask_id, pad_id, masked_lm_prob, np_rng, bos_id, eos_id, sentinel_tokens) and returns: train_sample