code: def replace_masks(
      self, texts, batch_size=32, progress_bar=None, device="cuda"
  ):
      print("Running perturbations")
      with torch.no_grad():
          n_expected = self.count_masks(texts)
          stop_id = self.mask_tokenizer.encode(
              f"<extra_id_{max(n_expected)}>"
          )[0]
          outputs = []
          for batch_texts in chunks(
              texts,
              batch_size,
              progress_bar=progress_bar,
              progress_text="Running perturbations",
          ):
              tokens = self.mask_tokenizer(
                  batch_texts, return_tensors="pt", padding=True
              ).to(device)
              outputs.extend(
                  self.mask_model.generate(
                      **tokens,
                      max_length=150,
                      do_sample=True,
                      top_p=0.96,
                      num_return_sequences=1,
                      eos_token_id=stop_id,
                  )
              )
      return self.mask_tokenizer.batch_decode(
          outputs, skip_special_tokens=False
      )
  
imports: import numpy
  from abc import ABC, abstractmethod
  from .text_utils import extract_non_overlapping_ngrams
label_desc: Use image node_id 5 for calling the PerturbationModel obj's underlying member method code with example usage: obj.replace_masks(texts, batch_size, progress_bar, device) and returns: self