class_docstr: Class for running attacks on a dataset with specified parameters. This
  class uses the :class:`~textattack.Attack` to actually run the attacks,
  while also providing useful features such as parallel processing,
  saving/resuming from a checkpint, logging to files and stdout.
  
  Args:
      attack (:class:`~textattack.Attack`):
          :class:`~textattack.Attack` used to actually carry out the attack.
      dataset (:class:`~textattack.datasets.Dataset`):
          Dataset to attack.
      attack_args (:class:`~textattack.AttackArgs`):
          Arguments for attacking the dataset. For default settings, look at the `AttackArgs` class.
  
  Example::
  
      >>> import textattack
      >>> import transformers
  
      >>> model = transformers.AutoModelForSequenceClassification.from_pretrained("textattack/bert-base-uncased-imdb")
      >>> tokenizer = transformers.AutoTokenizer.from_pretrained("textattack/bert-base-uncased-imdb")
      >>> model_wrapper = textattack.models.wrappers.HuggingFaceModelWrapper(model, tokenizer)
  
      >>> attack = textattack.attack_recipes.TextFoolerJin2019.build(model_wrapper)
      >>> dataset = textattack.datasets.HuggingFaceDataset("imdb", split="test")
  
      >>> # Attack 20 samples with CSV logging and checkpoint saved every 5 interval
      >>> attack_args = textattack.AttackArgs(
      ...     num_examples=20,
      ...     log_to_csv="log.csv",
      ...     checkpoint_interval=5,
      ...     checkpoint_dir="checkpoints",
      ...     disable_stdout=True
      ... )
  
      >>> attacker = textattack.Attacker(attack, dataset, attack_args)
      >>> attacker.attack_dataset()
class_docstr_tok: ["Class","for","running","attacks","on","a","dataset","with","specified","parameters",".","This","class","uses","the",":","class",":","`","~textattack.Attack","`","to","actually","run","the","attacks",",","while","also","providing","useful","features","such","as","parallel","processing",",","saving\/resuming","from","a","checkpint",",","logging","to","files","and","stdout",".","Args",":","attack","(",":","class",":","`","~textattack.Attack","`",")",":",":","class",":","`","~textattack.Attack","`","used","to","actually","carry","out","the","attack",".","dataset","(",":","class",":","`","~textattack.datasets.Dataset","`",")",":","Dataset","to","attack",".","attack_args","(",":","class",":","`","~textattack.AttackArgs","`",")",":","Arguments","for","attacking","the","dataset",".","For","default","settings",",","look","at","the","`","AttackArgs","`","class",".","Example",":",":",">",">",">","import","textattack",">",">",">","import","transformers",">",">",">","model","=","transformers.AutoModelForSequenceClassification.from_pretrained","(","``","textattack\/bert-base-uncased-imdb","''",")",">",">",">","tokenizer","=","transformers.AutoTokenizer.from_pretrained","(","``","textattack\/bert-base-uncased-imdb","''",")",">",">",">","model_wrapper","=","textattack.models.wrappers.HuggingFaceModelWrapper","(","model",",","tokenizer",")",">",">",">","attack","=","textattack.attack_recipes.TextFoolerJin2019.build","(","model_wrapper",")",">",">",">","dataset","=","textattack.datasets.HuggingFaceDataset","(","``","imdb","''",",","split=","''","test","''",")",">",">",">","#","Attack","20","samples","with","CSV","logging","and","checkpoint","saved","every","5","interval",">",">",">","attack_args","=","textattack.AttackArgs","(","...","num_examples=20",",","...","log_to_csv=","''","log.csv","''",",","...","checkpoint_interval=5",",","...","checkpoint_dir=","''","checkpoints","''",",","...","disable_stdout=True","...",")",">",">",">","attacker","=","textattack.Attacker","(","attack",",","dataset",",","attack_args",")",">",">",">","attacker.attack_dataset","(",")"]
code: def __init__(self, attack, dataset, attack_args=None):
      assert isinstance(
          attack, Attack
      ), f"`attack` argument must be of type `textattack.Attack`, but got type of `{type(attack)}`."
      assert isinstance(
          dataset, textattack.datasets.Dataset
      ), f"`dataset` must be of type `textattack.datasets.Dataset`, but got type `{type(dataset)}`."
  
      if attack_args:
          assert isinstance(
              attack_args, AttackArgs
          ), f"`attack_args` must be of type `textattack.AttackArgs`, but got type `{type(attack_args)}`."
      else:
          attack_args = AttackArgs()
  
      self.attack = attack
      self.dataset = dataset
      self.attack_args = attack_args
      self.attack_log_manager = None
  
      # This is to be set if loading from a checkpoint
      self._checkpoint = None
  
imports: import collections
  import logging
  import multiprocessing
  import os
  import queue
  import random
  import traceback
  import torch
  import tqdm
  import textattack
  from textattack.attack_results import FailedAttackResult, MaximizedAttackResult, SkippedAttackResult, SuccessfulAttackResult
  from textattack.shared.utils import logger
  from .attack import Attack
  from .attack_args import AttackArgs
label_desc: Use image node_id 1 to create a new Attacker object  with example: obj = Attacker(attack, dataset, attack_args)