class_docstr: Attack arguments to be passed to :class:`~textattack.Attacker`.
  
  Args:
      num_examples (:obj:`int`, 'optional`, defaults to :obj:`10`):
          The number of examples to attack. :obj:`-1` for entire dataset.
      num_successful_examples (:obj:`int`, `optional`, defaults to :obj:`None`):
          The number of successful adversarial examples we want. This is different from :obj:`num_examples`
          as :obj:`num_examples` only cares about attacking `N` samples while :obj:`num_successful_examples` aims to keep attacking
          until we have `N` successful cases.
          .. note::
              If set, this argument overrides `num_examples` argument.
      num_examples_offset (:obj: `int`, `optional`, defaults to :obj:`0`):
          The offset index to start at in the dataset.
      attack_n (:obj:`bool`, `optional`, defaults to :obj:`False`):
          Whether to run attack until total of `N` examples have been attacked (and not skipped).
      shuffle (:obj:`bool`, `optional`, defaults to :obj:`False`):
          If :obj:`True`, we randomly shuffle the dataset before attacking. However, this avoids actually shuffling
          the dataset internally and opts for shuffling the list of indices of examples we want to attack. This means
          :obj:`shuffle` can now be used with checkpoint saving.
      query_budget (:obj:`int`, `optional`, defaults to :obj:`None`):
          The maximum number of model queries allowed per example attacked.
          If not set, we use the query budget set in the :class:`~textattack.goal_functions.GoalFunction` object (which by default is :obj:`float("inf")`).
          .. note::
              Setting this overwrites the query budget set in :class:`~textattack.goal_functions.GoalFunction` object.
      checkpoint_interval (:obj:`int`, `optional`, defaults to :obj:`None`):
          If set, checkpoint will be saved after attacking every `N` examples. If :obj:`None` is passed, no checkpoints will be saved.
      checkpoint_dir (:obj:`str`, `optional`, defaults to :obj:`"checkpoints"`):
          The directory to save checkpoint files.
      random_seed (:obj:`int`, `optional`, defaults to :obj:`765`):
          Random seed for reproducibility.
      parallel (:obj:`False`, `optional`, defaults to :obj:`False`):
          If :obj:`True`, run attack using multiple CPUs/GPUs.
      num_workers_per_device (:obj:`int`, `optional`, defaults to :obj:`1`):
          Number of worker processes to run per device in parallel mode (i.e. :obj:`parallel=True`). For example, if you are using GPUs and :obj:`num_workers_per_device=2`,
          then 2 processes will be running in each GPU.
      log_to_txt (:obj:`str`, `optional`, defaults to :obj:`None`):
          If set, save attack logs as a `.txt` file to the directory specified by this argument.
          If the last part of the provided path ends with `.txt` extension, it is assumed to the desired path of the log file.
      log_to_csv (:obj:`str`, `optional`, defaults to :obj:`None`):
          If set, save attack logs as a CSV file to the directory specified by this argument.
          If the last part of the provided path ends with `.csv` extension, it is assumed to the desired path of the log file.
      csv_coloring_style (:obj:`str`, `optional`, defaults to :obj:`"file"`):
          Method for choosing how to mark perturbed parts of the text. Options are :obj:`"file"`, :obj:`"plain"`, and :obj:`"html"`.
          :obj:`"file"` wraps perturbed parts with double brackets :obj:`[[ <text> ]]` while :obj:`"plain"` does not mark the text in any way.
      log_to_visdom (:obj:`dict`, `optional`, defaults to :obj:`None`):
          If set, Visdom logger is used with the provided dictionary passed as a keyword arguments to :class:`~textattack.loggers.VisdomLogger`.
          Pass in empty dictionary to use default arguments. For custom logger, the dictionary should have the following
          three keys and their corresponding values: :obj:`"env", "port", "hostname"`.
      log_to_wandb(:obj:`dict`, `optional`, defaults to :obj:`None`):
          If set, WandB logger is used with the provided dictionary passed as a keyword arguments to :class:`~textattack.loggers.WeightsAndBiasesLogger`.
          Pass in empty dictionary to use default arguments. For custom logger, the dictionary should have the following
          key and its corresponding value: :obj:`"project"`.
      disable_stdout (:obj:`bool`, `optional`, defaults to :obj:`False`):
          Disable displaying individual attack results to stdout.
      silent (:obj:`bool`, `optional`, defaults to :obj:`False`):
          Disable all logging (except for errors). This is stronger than :obj:`disable_stdout`.
      enable_advance_metrics (:obj:`bool`, `optional`, defaults to :obj:`False`):
          Enable calculation and display of optional advance post-hoc metrics like perplexity, grammar errors, etc.
class_docstr_tok: ["Attack","arguments","to","be","passed","to",":","class",":","`","~textattack.Attacker","`",".","Args",":","num_examples","(",":","obj",":","`","int","`",",","'optional","`",",","defaults","to",":","obj",":","`","10","`",")",":","The","number","of","examples","to","attack",".",":","obj",":","`","-1","`","for","entire","dataset",".","num_successful_examples","(",":","obj",":","`","int","`",",","`","optional","`",",","defaults","to",":","obj",":","`","None","`",")",":","The","number","of","successful","adversarial","examples","we","want",".","This","is","different","from",":","obj",":","`","num_examples","`","as",":","obj",":","`","num_examples","`","only","cares","about","attacking","`","N","`","samples","while",":","obj",":","`","num_successful_examples","`","aims","to","keep","attacking","until","we","have","`","N","`","successful","cases",".","..","note",":",":","If","set",",","this","argument","overrides","`","num_examples","`","argument",".","num_examples_offset","(",":","obj",":","`","int","`",",","`","optional","`",",","defaults","to",":","obj",":","`","0","`",")",":","The","offset","index","to","start","at","in","the","dataset",".","attack_n","(",":","obj",":","`","bool","`",",","`","optional","`",",","defaults","to",":","obj",":","`","False","`",")",":","Whether","to","run","attack","until","total","of","`","N","`","examples","have","been","attacked","(","and","not","skipped",")",".","shuffle","(",":","obj",":","`","bool","`",",","`","optional","`",",","defaults","to",":","obj",":","`","False","`",")",":","If",":","obj",":","`","True","`",",","we","randomly","shuffle","the","dataset","before","attacking",".","However",",","this","avoids","actually","shuffling","the","dataset","internally","and","opts","for","shuffling","the","list","of","indices","of","examples","we","want","to","attack",".","This","means",":","obj",":","`","shuffle","`","can","now","be","used","with","checkpoint","saving",".","query_budget","(",":","obj",":","`","int","`",",","`","optional","`",",","defaults","to",":","obj",":","`","None","`",")",":","The","maximum","number","of","model","queries","allowed","per","example","attacked",".","If","not","set",",","we","use","the","query","budget","set","in","the",":","class",":","`","~textattack.goal_functions.GoalFunction","`","object","(","which","by","default","is",":","obj",":","`","float","(","``","inf","''",")","`",")",".","..","note",":",":","Setting","this","overwrites","the","query","budget","set","in",":","class",":","`","~textattack.goal_functions.GoalFunction","`","object",".","checkpoint_interval","(",":","obj",":","`","int","`",",","`","optional","`",",","defaults","to",":","obj",":","`","None","`",")",":","If","set",",","checkpoint","will","be","saved","after","attacking","every","`","N","`","examples",".","If",":","obj",":","`","None","`","is","passed",",","no","checkpoints","will","be","saved",".","checkpoint_dir","(",":","obj",":","`","str","`",",","`","optional","`",",","defaults","to",":","obj",":","`","``","checkpoints","''","`",")",":","The","directory","to","save","checkpoint","files",".","random_seed","(",":","obj",":","`","int","`",",","`","optional","`",",","defaults","to",":","obj",":","`","765","`",")",":","Random","seed","for","reproducibility",".","parallel","(",":","obj",":","`","False","`",",","`","optional","`",",","defaults","to",":","obj",":","`","False","`",")",":","If",":","obj",":","`","True","`",",","run","attack","using","multiple","CPUs\/GPUs",".","num_workers_per_device","(",":","obj",":","`","int","`",",","`","optional","`",",","defaults","to",":","obj",":","`","1","`",")",":","Number","of","worker","processes","to","run","per","device","in","parallel","mode","(","i.e",".",":","obj",":","`","parallel=True","`",")",".","For","example",",","if","you","are","using","GPUs","and",":","obj",":","`","num_workers_per_device=2","`",",","then","2","processes","will","be","running","in","each","GPU",".","log_to_txt","(",":","obj",":","`","str","`",",","`","optional","`",",","defaults","to",":","obj",":","`","None","`",")",":","If","set",",","save","attack","logs","as","a","`",".txt","`","file","to","the","directory","specified","by","this","argument",".","If","the","last","part","of","the","provided","path","ends","with","`",".txt","`","extension",",","it","is","assumed","to","the","desired","path","of","the","log","file",".","log_to_csv","(",":","obj",":","`","str","`",",","`","optional","`",",","defaults","to",":","obj",":","`","None","`",")",":","If","set",",","save","attack","logs","as","a","CSV","file","to","the","directory","specified","by","this","argument",".","If","the","last","part","of","the","provided","path","ends","with","`",".csv","`","extension",",","it","is","assumed","to","the","desired","path","of","the","log","file",".","csv_coloring_style","(",":","obj",":","`","str","`",",","`","optional","`",",","defaults","to",":","obj",":","`","``","file","''","`",")",":","Method","for","choosing","how","to","mark","perturbed","parts","of","the","text",".","Options","are",":","obj",":","`","``","file","''","`",",",":","obj",":","`","``","plain","''","`",",","and",":","obj",":","`","``","html","''","`",".",":","obj",":","`","``","file","''","`","wraps","perturbed","parts","with","double","brackets",":","obj",":","`","[","[","<","text",">","]","]","`","while",":","obj",":","`","``","plain","''","`","does","not","mark","the","text","in","any","way",".","log_to_visdom","(",":","obj",":","`","dict","`",",","`","optional","`",",","defaults","to",":","obj",":","`","None","`",")",":","If","set",",","Visdom","logger","is","used","with","the","provided","dictionary","passed","as","a","keyword","arguments","to",":","class",":","`","~textattack.loggers.VisdomLogger","`",".","Pass","in","empty","dictionary","to","use","default","arguments",".","For","custom","logger",",","the","dictionary","should","have","the","following","three","keys","and","their","corresponding","values",":",":","obj",":","`","``","env","''",",","``","port","''",",","``","hostname","''","`",".","log_to_wandb","(",":","obj",":","`","dict","`",",","`","optional","`",",","defaults","to",":","obj",":","`","None","`",")",":","If","set",",","WandB","logger","is","used","with","the","provided","dictionary","passed","as","a","keyword","arguments","to",":","class",":","`","~textattack.loggers.WeightsAndBiasesLogger","`",".","Pass","in","empty","dictionary","to","use","default","arguments",".","For","custom","logger",",","the","dictionary","should","have","the","following","key","and","its","corresponding","value",":",":","obj",":","`","``","project","''","`",".","disable_stdout","(",":","obj",":","`","bool","`",",","`","optional","`",",","defaults","to",":","obj",":","`","False","`",")",":","Disable","displaying","individual","attack","results","to","stdout",".","silent","(",":","obj",":","`","bool","`",",","`","optional","`",",","defaults","to",":","obj",":","`","False","`",")",":","Disable","all","logging","(","except","for","errors",")",".","This","is","stronger","than",":","obj",":","`","disable_stdout","`",".","enable_advance_metrics","(",":","obj",":","`","bool","`",",","`","optional","`",",","defaults","to",":","obj",":","`","False","`",")",":","Enable","calculation","and","display","of","optional","advance","post-hoc","metrics","like","perplexity",",","grammar","errors",",","etc","."]
code: def __post_init__(self):
      if self.num_successful_examples:
          self.num_examples = None
      if self.num_examples:
          assert (
              self.num_examples >= 0 or self.num_examples == -1
          ), "`num_examples` must be greater than or equal to 0 or equal to -1."
      if self.num_successful_examples:
          assert (
              self.num_successful_examples >= 0
          ), "`num_examples` must be greater than or equal to 0."
  
      if self.query_budget:
          assert (
              self.query_budget > 0
          ), "`query_budget` must be greater than 0."
  
      if self.checkpoint_interval:
          assert (
              self.checkpoint_interval > 0
          ), "`checkpoint_interval` must be greater than 0."
  
      assert (
          self.num_workers_per_device > 0
      ), "`num_workers_per_device` must be greater than 0."
  
imports: from dataclasses import dataclass, field
  import json
  import os
  import sys
  import time
  from typing import Dict, Optional
  import textattack
  from textattack.shared.utils import ARGS_SPLIT_TOKEN, load_module_from_file
  from .attack import Attack
  from .dataset_args import DatasetArgs
  from .model_args import ModelArgs
label_desc: Use image node_id 1 for calling the AttackArgs obj's underlying member method code with example usage: obj.__post_init__() without return types