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: Initialize the goal function with model.
  
  :param model: the model to attack.
docstr_tok: ["Initialize","the","goal","function","with","model",".",":","param","model",":","the","model","to","attack","."]
code: def init_goal_function(self, model):
      """
      Initialize the goal function with model.
  
      :param model: the model to attack.
      """
      self.goal_function = self.goal_function(model)
  
      # Give search method access to functions for getting transformations
      # and evaluating them
      self.search_method.get_transformations = self.get_transformations
      # Give search method access to self.goal_function for model query count,
      # etc.
      self.search_method.goal_function = self.goal_function
      # The search method only needs access to the first argument. The second
      # is only used by the attack class when checking whether to skip the
      # sample
      self.search_method.get_goal_results = (
          lambda attacked_text_list: self.goal_function.get_results(
              attacked_text_list
          )
      )
      self.search_method.filter_transformations = (
          self.filter_transformations
      )
      if not self.search_method.is_black_box:
          self.search_method.get_model = (
              lambda: self.goal_function.model
          )
  
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 2 for calling the Attack obj's underlying member method code with example usage: obj.init_goal_function(model) without return types