class_docstr: Attacks a model with word substiutitions using a Particle Swarm
  Optimization (PSO) algorithm. Some key hyper-parameters are setup according
  to the original paper:
  
  "We adjust PSO on the validation set of SST and set ω_1 as 0.8 and ω_2 as 0.2.
  We set the max velocity of the particles V_{max} to 3, which means the changing
  probability of the particles ranges from 0.047 (sigmoid(-3)) to 0.953 (sigmoid(3))."
  
  Args:
      pop_size (:obj:`int`, optional): The population size. Defaults to 60.
      max_iters (:obj:`int`, optional): The maximum number of iterations to use. Defaults to 20.
      post_turn_check (:obj:`bool`, optional): If `True`, check if new position reached by moving passes the constraints. Defaults to `True`
      max_turn_retries (:obj:`bool`, optional): Maximum number of movement retries if new position after turning fails to pass the constraints.
          Applied only when `post_movement_check` is set to `True`.
          Setting it to 0 means we immediately take the old position as the new position upon failure.
class_docstr_tok: ["Attacks","a","model","with","word","substiutitions","using","a","Particle","Swarm","Optimization","(","PSO",")","algorithm",".","Some","key","hyper-parameters","are","setup","according","to","the","original","paper",":","''","We","adjust","PSO","on","the","validation","set","of","SST","and","set","\u03c9_1","as","0.8","and","\u03c9_2","as","0.2",".","We","set","the","max","velocity","of","the","particles","V_","{","max","}","to","3",",","which","means","the","changing","probability","of","the","particles","ranges","from","0.047","(","sigmoid","(","-3",")",")","to","0.953","(","sigmoid","(","3",")",")",".","''","Args",":","pop_size","(",":","obj",":","`","int","`",",","optional",")",":","The","population","size",".","Defaults","to","60.","max_iters","(",":","obj",":","`","int","`",",","optional",")",":","The","maximum","number","of","iterations","to","use",".","Defaults","to","20.","post_turn_check","(",":","obj",":","`","bool","`",",","optional",")",":","If","`","True","`",",","check","if","new","position","reached","by","moving","passes","the","constraints",".","Defaults","to","`","True","`","max_turn_retries","(",":","obj",":","`","bool","`",",","optional",")",":","Maximum","number","of","movement","retries","if","new","position","after","turning","fails","to","pass","the","constraints",".","Applied","only","when","`","post_movement_check","`","is","set","to","`","True","`",".","Setting","it","to","0","means","we","immediately","take","the","old","position","as","the","new","position","upon","failure","."]
docstr: The genetic algorithm is specifically designed for word
  substitutions.
docstr_tok: ["The","genetic","algorithm","is","specifically","designed","for","word","substitutions","."]
code: def check_transformation_compatibility(self, transformation):
      """The genetic algorithm is specifically designed for word
      substitutions."""
      return transformation_consists_of_word_swaps(transformation)
  
file_path: TextAttack/textattack/search_methods/particle_swarm_optimization.py
imports: import copy
  import numpy
  from textattack.goal_function_results import GoalFunctionResultStatus
  from textattack.search_methods import PopulationBasedSearch, PopulationMember
  from textattack.shared import utils
  from textattack.shared.validators import transformation_consists_of_word_swaps
label_desc: Use image node_id 8 for calling the ParticleSwarmOptimization obj's underlying member method code with example usage: obj.check_transformation_compatibility(transformation) and returns: transformation_consists_of_word_swaps