code: def add_insertion_noise(self, tokens, p):
      if p == 0.0:
          return tokens
  
      num_tokens = len(tokens)
      n = int(math.ceil(num_tokens * p))
  
      noise_indices = torch.randperm(num_tokens + n - 2)[:n] + 1
      noise_mask = torch.zeros(size=(num_tokens + n,), dtype=torch.bool)
      noise_mask[noise_indices] = 1
      result = torch.LongTensor(n + len(tokens)).fill_(-1)
  
      num_random = int(math.ceil(n * self.random_ratio))
      result[noise_indices[num_random:]] = self.mask_idx
      result[noise_indices[:num_random]] = self.voc_valid_ids[
          torch.randint(0, self.voc_valid_size - 1, size=(num_random,))
      ]
  
      result[~noise_mask] = tokens
  
      assert (result >= 0).all()
      return result
  
file_path: fairseq/examples/speech_text_joint_to_text/data/pair_denoising_dataset.py
imports: import copy
  import math
  import re
  import torch
  from fairseq.data import data_utils
  from fairseq.data.language_pair_dataset import LanguagePairDataset
label_desc: Use image node_id 7 for calling the LanguagePairDenoisingDataset obj's underlying member method code with example usage: obj.add_insertion_noise(tokens, p) and returns: result, tokens