docstr: perturb the text, generation n_samples x perturbed texts.
  parts: list of parts to perturb
  parts_to_replace: indices of parts to replace
  max_parts_to_perturb: maximum number of chunks to replace
  n_samples: number of perturbed texts to generate
docstr_tok: ["perturb","the","text",",","generation","n_samples","x","perturbed","texts",".","parts",":","list","of","parts","to","perturb","parts_to_replace",":","indices","of","parts","to","replace","max_parts_to_perturb",":","maximum","number","of","chunks","to","replace","n_samples",":","number","of","perturbed","texts","to","generate"]
code: def __call__(
      self,
      parts,
      max_parts_to_perturb=2,
      n_samples=50,
      parts_to_replace=None,
      *args,
      **kwargs,
  ):
      """
      perturb the text, generation n_samples x perturbed texts.
      parts: list of parts to perturb
      parts_to_replace: indices of parts to replace
      max_parts_to_perturb: maximum number of chunks to replace
      n_samples: number of perturbed texts to generate
      """
      if parts_to_replace is None:
          parts_to_replace = np.arange(len(parts))
  
      assert max_parts_to_perturb <= (
          len(parts_to_replace) - 1
      ), "max_parts_to_perturb should be less than or equal to the number of parts to replace - 1"
  
      # Sample the number of chunks to replace
      sample_k = np.random.randint(
          1, max_parts_to_perturb + 1, size=n_samples
      )
  
      indices = []
      perturbed_texts = []
      for k in sample_k:
          sampled_indices = np.random.choice(
              parts_to_replace, k, replace=False
          )
          perturbed_text = self.replace(parts, sampled_indices)
          # If consecutive ones are sampled, combine them into a single one.
          perturbed_texts.append("".join(perturbed_text))
          indices.append(list(sorted(sampled_indices)))
  
      return perturbed_texts, indices
  
imports: import numpy
  from abc import ABC, abstractmethod
  from .text_utils import extract_non_overlapping_ngrams
label_desc: Use image node_id 3 for calling the RemovalPerturbation obj's underlying member method code with example usage: obj.__call__(parts, max_parts_to_perturb, n_samples, parts_to_replace) and returns: perturbed_texts,  indices