class_docstr: Attack args for command line execution.
  
  This requires more arguments to
  create ``Attack`` object as specified.
  Args:
      transformation (:obj:`str`, `optional`, defaults to :obj:`"word-swap-embedding"`):
          Name of transformation to use.
      constraints (:obj:`list[str]`, `optional`, defaults to :obj:`["repeat", "stopword"]`):
          List of names of constraints to use.
      goal_function (:obj:`str`, `optional`, defaults to :obj:`"untargeted-classification"`):
          Name of goal function to use.
      search_method (:obj:`str`, `optional`, defualts to :obj:`"greedy-word-wir"`):
          Name of search method to use.
      attack_recipe (:obj:`str`, `optional`, defaults to :obj:`None`):
          Name of attack recipe to use.
          .. note::
              Setting this overrides any previous selection of transformation, constraints, goal function, and search method.
      attack_from_file (:obj:`str`, `optional`, defaults to :obj:`None`):
          Path of `.py` file from which to load attack from. Use `<path>^<variable_name>` to specifiy which variable to import from the file.
          .. note::
              If this is set, it overrides any previous selection of transformation, constraints, goal function, and search method
      interactive (:obj:`bool`, `optional`, defaults to :obj:`False`):
          If `True`, carry attack in interactive mode.
      parallel (:obj:`bool`, `optional`, defaults to :obj:`False`):
          If `True`, attack in parallel.
      model_batch_size (:obj:`int`, `optional`, defaults to :obj:`32`):
          The batch size for making queries to the victim model.
      model_cache_size (:obj:`int`, `optional`, defaults to :obj:`2**18`):
          The maximum number of items to keep in the model results cache at once.
      constraint-cache-size (:obj:`int`, `optional`, defaults to :obj:`2**18`):
          The maximum number of items to keep in the constraints cache at once.
class_docstr_tok: ["Attack","args","for","command","line","execution",".","This","requires","more","arguments","to","create","``","Attack","``","object","as","specified",".","Args",":","transformation","(",":","obj",":","`","str","`",",","`","optional","`",",","defaults","to",":","obj",":","`","``","word-swap-embedding","''","`",")",":","Name","of","transformation","to","use",".","constraints","(",":","obj",":","`","list","[","str","]","`",",","`","optional","`",",","defaults","to",":","obj",":","`","[","``","repeat","''",",","``","stopword","''","]","`",")",":","List","of","names","of","constraints","to","use",".","goal_function","(",":","obj",":","`","str","`",",","`","optional","`",",","defaults","to",":","obj",":","`","``","untargeted-classification","''","`",")",":","Name","of","goal","function","to","use",".","search_method","(",":","obj",":","`","str","`",",","`","optional","`",",","defualts","to",":","obj",":","`","``","greedy-word-wir","''","`",")",":","Name","of","search","method","to","use",".","attack_recipe","(",":","obj",":","`","str","`",",","`","optional","`",",","defaults","to",":","obj",":","`","None","`",")",":","Name","of","attack","recipe","to","use",".","..","note",":",":","Setting","this","overrides","any","previous","selection","of","transformation",",","constraints",",","goal","function",",","and","search","method",".","attack_from_file","(",":","obj",":","`","str","`",",","`","optional","`",",","defaults","to",":","obj",":","`","None","`",")",":","Path","of","`",".py","`","file","from","which","to","load","attack","from",".","Use","`","<","path",">","^","<","variable_name",">","`","to","specifiy","which","variable","to","import","from","the","file",".","..","note",":",":","If","this","is","set",",","it","overrides","any","previous","selection","of","transformation",",","constraints",",","goal","function",",","and","search","method","interactive","(",":","obj",":","`","bool","`",",","`","optional","`",",","defaults","to",":","obj",":","`","False","`",")",":","If","`","True","`",",","carry","attack","in","interactive","mode",".","parallel","(",":","obj",":","`","bool","`",",","`","optional","`",",","defaults","to",":","obj",":","`","False","`",")",":","If","`","True","`",",","attack","in","parallel",".","model_batch_size","(",":","obj",":","`","int","`",",","`","optional","`",",","defaults","to",":","obj",":","`","32","`",")",":","The","batch","size","for","making","queries","to","the","victim","model",".","model_cache_size","(",":","obj",":","`","int","`",",","`","optional","`",",","defaults","to",":","obj",":","`","2","*","*","18","`",")",":","The","maximum","number","of","items","to","keep","in","the","model","results","cache","at","once",".","constraint-cache-size","(",":","obj",":","`","int","`",",","`","optional","`",",","defaults","to",":","obj",":","`","2","*","*","18","`",")",":","The","maximum","number","of","items","to","keep","in","the","constraints","cache","at","once","."]
docstr: Given ``CommandLineArgs`` and ``ModelWrapper``, return specified
  ``Attack`` object.
docstr_tok: ["Given","``","CommandLineArgs","``","and","``","ModelWrapper","``",",","return","specified","``","Attack","``","object","."]
code: def _create_attack_from_args(cls, args, model_wrapper):
      """Given ``CommandLineArgs`` and ``ModelWrapper``, return specified
      ``Attack`` object."""
  
      assert isinstance(
          args, cls
      ), f"Expect args to be of type `{type(cls)}`, but got type `{type(args)}`."
  
      if args.attack_recipe:
          if ARGS_SPLIT_TOKEN in args.attack_recipe:
              recipe_name, params = args.attack_recipe.split(
                  ARGS_SPLIT_TOKEN
              )
              if recipe_name not in ATTACK_RECIPE_NAMES:
                  raise ValueError(
                      f"Error: unsupported recipe {recipe_name}"
                  )
              recipe = eval(
                  f"{ATTACK_RECIPE_NAMES[recipe_name]}.build(model_wrapper, {params})"
              )
          elif args.attack_recipe in ATTACK_RECIPE_NAMES:
              recipe = eval(
                  f"{ATTACK_RECIPE_NAMES[args.attack_recipe]}.build(model_wrapper)"
              )
          else:
              raise ValueError(f"Invalid recipe {args.attack_recipe}")
          if args.query_budget:
              recipe.goal_function.query_budget = args.query_budget
          recipe.goal_function.model_cache_size = args.model_cache_size
          recipe.goal_function.batch_size = args.model_batch_size
          recipe.constraint_cache_size = args.constraint_cache_size
          return recipe
      elif args.attack_from_file:
          if ARGS_SPLIT_TOKEN in args.attack_from_file:
              attack_file, attack_name = args.attack_from_file.split(
                  ARGS_SPLIT_TOKEN
              )
          else:
              attack_file, attack_name = args.attack_from_file, "attack"
          attack_module = load_module_from_file(attack_file)
          if not hasattr(attack_module, attack_name):
              raise ValueError(
                  f"Loaded `{attack_file}` but could not find `{attack_name}`."
              )
          attack_func = getattr(attack_module, attack_name)
          return attack_func(model_wrapper)
      else:
          goal_function = cls._create_goal_function_from_args(
              args, model_wrapper
          )
          transformation = cls._create_transformation_from_args(
              args, model_wrapper
          )
          constraints = cls._create_constraints_from_args(args)
          if ARGS_SPLIT_TOKEN in args.search_method:
              search_name, params = args.search_method.split(
                  ARGS_SPLIT_TOKEN
              )
              if search_name not in SEARCH_METHOD_CLASS_NAMES:
                  raise ValueError(
                      f"Error: unsupported search {search_name}"
                  )
              search_method = eval(
                  f"{SEARCH_METHOD_CLASS_NAMES[search_name]}({params})"
              )
          elif args.search_method in SEARCH_METHOD_CLASS_NAMES:
              search_method = eval(
                  f"{SEARCH_METHOD_CLASS_NAMES[args.search_method]}()"
              )
          else:
              raise ValueError(
                  f"Error: unsupported attack {args.search_method}"
              )
  
      return Attack(
          goal_function,
          constraints,
          transformation,
          search_method,
          constraint_cache_size=args.constraint_cache_size,
      )
  
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 5 for calling the _CommandLineAttackArgs obj's underlying member method code with example usage: obj._create_attack_from_args(cls, args, model_wrapper) and returns: Attack, recipe, attack_func