class_docstr: An attack generates adversarial examples on text.
  
  This is an abstract class that contains main helper functionality for
  attacks. An attack is comprised of a search method, goal function,
  a transformation, and a set of one or more linguistic constraints that
  successful examples must meet.
class_docstr_tok: ["An","attack","generates","adversarial","examples","on","text",".","This","is","an","abstract","class","that","contains","main","helper","functionality","for","attacks",".","An","attack","is","comprised","of","a","search","method",",","goal","function",",","a","transformation",",","and","a","set","of","one","or","more","linguistic","constraints","that","successful","examples","must","meet","."]
docstr: Filters a list of potential transformed texts based on
  ``self.constraints`` Utilizes an LRU cache to attempt to avoid
  recomputing common transformations.
  
  :param transformed_texts: A list of candidate transformed
      ``AttackedText`` to filter.
  :param current_text: The current ``AttackedText`` on which the
      transformation was applied.
  :param original_text: The original ``AttackedText`` from which the
      attack started.
  :return: The list of filtered ``AttackedText`.
docstr_tok: ["Filters","a","list","of","potential","transformed","texts","based","on","``","self.constraints","``","Utilizes","an","LRU","cache","to","attempt","to","avoid","recomputing","common","transformations",".",":","param","transformed_texts",":","A","list","of","candidate","transformed","``","AttackedText","``","to","filter",".",":","param","current_text",":","The","current","``","AttackedText","``","on","which","the","transformation","was","applied",".",":","param","original_text",":","The","original","``","AttackedText","``","from","which","the","attack","started",".",":","return",":","The","list","of","filtered","``","AttackedText","`","."]
code: def filter_transformations(
      self, transformed_texts, current_text, original_text=None
  ):
      """
      Filters a list of potential transformed texts based on
      ``self.constraints`` Utilizes an LRU cache to attempt to avoid
      recomputing common transformations.
  
      :param transformed_texts: A list of candidate transformed
          ``AttackedText`` to filter.
      :param current_text: The current ``AttackedText`` on which the
          transformation was applied.
      :param original_text: The original ``AttackedText`` from which the
          attack started.
      :return: The list of filtered ``AttackedText`.
  
      """
      # Remove any occurences of current_text in transformed_texts
      transformed_texts = [
          t for t in transformed_texts if t.text != current_text.text
      ]
      # Populate cache with transformed_texts
      uncached_texts = []
      filtered_texts = []
      for transformed_text in transformed_texts:
          if (
              current_text,
              transformed_text,
          ) not in self.constraints_cache:
              uncached_texts.append(transformed_text)
          else:
              # promote transformed_text to the top of the LRU cache
              self.constraints_cache[
                  (current_text, transformed_text)
              ] = self.constraints_cache[
                  (current_text, transformed_text)
              ]
              if self.constraints_cache[
                  (current_text, transformed_text)
              ]:
                  filtered_texts.append(transformed_text)
      filtered_texts += self._filter_transformations_uncached(
          uncached_texts, current_text, original_text=original_text
      )
      # Sort transformations to ensure order is preserved between runs
      filtered_texts.sort(key=lambda t: t.text)
      return filtered_texts
  
imports: import lru
  from collections import deque
  from ...common import logger
  from textattack.attack_results import FailedAttackResult, MaximizedAttackResult, SuccessfulAttackResult
  from textattack.goal_function_results import GoalFunctionResultStatus
  from textattack.shared import AttackedText, utils
  from textattack.transformations import CompositeTransformation
label_desc: Use image node_id 7 for calling the Attack obj's underlying member method code with example usage: obj.filter_transformations(transformed_texts, current_text, original_text) and returns: filtered_texts