class_docstr: Dataset for unlearning span corruption (https://arxiv.org/abs/2104.08691) in T5 models.
  Corresponds to the prefix-LM objective in the T5 paper (Table 3 in https://arxiv.org/abs/1910.10683).
code: def get_prefix_lm_sample(
      cls,
      sample,
      max_seq_length_encoder,
      max_seq_length_decoder,
      np_rng,
      tokenizer,
      pivot_mean=0.25,
      pivot_distribution=LengthDistribution.uniform,
      add_eos=False,
  ):
      # get random split index
      if (
          pivot_distribution == LengthDistribution.truncated_normal
          and (pivot_mean < 0.0 or pivot_mean > 1.0)
      ):
          raise ValueError(
              f"Invalid pivot_mean: {pivot_mean}. Must be in [0.0, 1.0]. It is a fraction of the encoder sequence length."
          )
  
      # 1) If the sample is larger than max encoder sequence length, use max encoder sequence length
      # 2) Otherwwise use sample length - 1 so that there is at least one token on the decoder.
      max_split_idx = min(len(sample) - 1, max_seq_length_encoder)
  
      if pivot_distribution == LengthDistribution.uniform:
          split_idx = np_rng.randint(0, max_split_idx)
      elif pivot_distribution == LengthDistribution.truncated_normal:
          loc = pivot_mean * max_split_idx
          split_idx = np.clip(
              int(np_rng.normal(loc=loc, scale=loc)),
              0,
              max_split_idx,
          )
      else:
          raise ValueError(
              f"Invalid pivot_distribution: {pivot_distribution}"
          )
  
      # Encoder inputs get truncated based on the split indx
      tokens_enc = np.concatenate(
          [
              sample[:split_idx],
              [tokenizer.pad_id] * (max_seq_length_encoder - split_idx),
          ]
      ).astype(np.int64)
  
      # The decoder sequence is never truncated and is always of max decoder length.
      offset = 1 if add_eos else 0
      tokens_dec = sample[
          split_idx : split_idx + max_seq_length_decoder - offset
      ]
  
      # NOTE: Add bos only and not eos because the model will always generate till max seq length.
      example = np.concatenate([[tokenizer.bos_id], tokens_dec])
      if add_eos:
          example = np.concatenate([example, [tokenizer.eos_id]])
  
      # Example can be + 1 over sequence length at this point since we'll be shifting by 1 to create the inputs and outputs to the decoder.
      assert len(example) <= max_seq_length_decoder + 1
      tokens_dec = np.concatenate(
          [
              example,
              [tokenizer.pad_id]
              * (max_seq_length_decoder - len(example) + 1),
          ]
      ).astype(np.int64)
  
      # Shift sequences for teacher forcing
      tokens_dec_in = tokens_dec[:-1]
      labels = tokens_dec[1:]
  
      # Create attention masks
      enc_mask = (tokens_enc != tokenizer.pad_id).astype(np.int64)
      dec_mask = (tokens_dec_in != tokenizer.pad_id).astype(np.int64)
  
      loss_mask = dec_mask
  
      train_sample = {
          "text_enc": tokens_enc,
          "text_dec": tokens_dec_in,
          "labels": labels,
          "loss_mask": loss_mask,
          "enc_mask": enc_mask,
          "dec_mask": dec_mask,
      }
      return train_sample
  
imports: import numpy
  from nemo.collections.nlp.data.language_modeling.megatron.gpt_dataset import GPTDataset
  from nemo.collections.nlp.data.language_modeling.megatron.length_distribution_type import LengthDistribution
label_desc: Use image node_id 2 for calling the T5LMAdaptedDataset obj's underlying member method code with example usage: obj.get_prefix_lm_sample(cls, sample, max_seq_length_encoder, max_seq_length_decoder, np_rng, tokenizer, pivot_mean, pivot_distribution, add_eos) and returns: train_sample