class_docstr: A constraint representing a maximum allowed perturbed words.
  
  Args:
      max_num_words (:obj:`int`, optional): Maximum number of perturbed words allowed.
      max_percent (:obj: `float`, optional): Maximum percentage of words allowed to be perturbed.
      compare_against_original (bool):  If `True`, compare new `x_adv` against the original `x`.
          Otherwise, compare it against the previous `x_adv`.
class_docstr_tok: ["A","constraint","representing","a","maximum","allowed","perturbed","words",".","Args",":","max_num_words","(",":","obj",":","`","int","`",",","optional",")",":","Maximum","number","of","perturbed","words","allowed",".","max_percent","(",":","obj",":","`","float","`",",","optional",")",":","Maximum","percentage","of","words","allowed","to","be","perturbed",".","compare_against_original","(","bool",")",":","If","`","True","`",",","compare","new","`","x_adv","`","against","the","original","`","x","`",".","Otherwise",",","compare","it","against","the","previous","`","x_adv","`","."]
code: def _check_constraint(self, transformed_text, reference_text):
      num_words_diff = len(
          transformed_text.all_words_diff(reference_text)
      )
      if self.max_percent:
          min_num_words = min(
              len(transformed_text.words), len(reference_text.words)
          )
          max_words_perturbed = math.ceil(
              min_num_words * (self.max_percent)
          )
          max_percent_met = num_words_diff <= max_words_perturbed
      else:
          max_percent_met = True
      if self.max_num_words:
          max_num_words_met = num_words_diff <= self.max_num_words
      else:
          max_num_words_met = True
  
      return max_percent_met and max_num_words_met
  
imports: import math
  from textattack.constraints import Constraint
label_desc: Use image node_id 2 for calling the MaxWordsPerturbed obj's underlying member method code with example usage: obj._check_constraint(transformed_text, reference_text) and returns: unknown