docstr: Given a list of generated texts, simulate attack and return performance metrics.
  
  :param texts_original: List of original texts
  :type texts_original: list
  :param texts_generated: List of generated texts (output of generate function)
  :type texts_generated: list
  :param predict_function: Function that maps strings to classification label (0 or 1)
  :type predict_function: (str) -> int
  :param save: Whether the generated metrics DataFrames should be pickled as output
  :type save: bool
  :return: Two DataFrames containing performance metrics
  :rtype: (pd.DataFrame, pd.DataFrame)
docstr_tok: ["Given","a","list","of","generated","texts",",","simulate","attack","and","return","performance","metrics",".",":","param","texts_original",":","List","of","original","texts",":","type","texts_original",":","list",":","param","texts_generated",":","List","of","generated","texts","(","output","of","generate","function",")",":","type","texts_generated",":","list",":","param","predict_function",":","Function","that","maps","strings","to","classification","label","(","0","or","1",")",":","type","predict_function",":","(","str",")","-",">","int",":","param","save",":","Whether","the","generated","metrics","DataFrames","should","be","pickled","as","output",":","type","save",":","bool",":","return",":","Two","DataFrames","containing","performance","metrics",":","rtype",":","(","pd.DataFrame",",","pd.DataFrame",")"]
code: def attack(
      self,
      texts_original,
      texts_generated,
      predict_function,
      save=False,
  ):
      """
      Given a list of generated texts, simulate attack and return performance metrics.
  
      :param texts_original: List of original texts
      :type texts_original: list
      :param texts_generated: List of generated texts (output of generate function)
      :type texts_generated: list
      :param predict_function: Function that maps strings to classification label (0 or 1)
      :type predict_function: (str) -> int
      :param save: Whether the generated metrics DataFrames should be pickled as output
      :type save: bool
      :return: Two DataFrames containing performance metrics
      :rtype: (pd.DataFrame, pd.DataFrame)
      """
      texts_original_flat = [
          texts_original[t_g[2]] for t_g in texts_generated
      ]
      texts_generated_flat = [t_g[0] for t_g in texts_generated]
      attacks_applied = [t_g[1] for t_g in texts_generated]
  
      original_preds = [
          predict_function(t_o) for t_o in texts_original_flat
      ]
      generated_preds = [
          predict_function(t_g) for t_g in texts_generated_flat
      ]
  
      self.print_progress(
          "Accuracy on original texts: {}".format(
              1.0 * sum(original_preds) / len(original_preds)
          )
      )
      self.print_progress(
          "Accuracy on generated texts: {}".format(
              1.0 * sum(generated_preds) / len(generated_preds)
          )
      )
  
      misclassifications_single = self._get_misclassifications_single(
          original_preds, generated_preds, attacks_applied
      )
      misclassifications_group = self._get_misclassifications_group(
          original_preds, generated_preds, attacks_applied
      )
  
      if save:
          pickle_to_file(
              "misclassifications_df_single.pkl",
              misclassifications_single,
          )
          pickle_to_file(
              "misclassifications_df_group.pkl",
              misclassifications_group,
          )
  
      return misclassifications_single, misclassifications_group
  
file_path: artificial-adversary/Adversary/adversary.py
imports: from copy import copy
  from functools import partial
  from random import random, seed
  import pandas
  from textblob import TextBlob
  from Adversary.attacks import *
  from Adversary.utils import *
label_desc: Use image node_id 6 for calling the Adversary obj's underlying member method code with example usage: obj.attack(texts_original, texts_generated, predict_function, save) and returns: misclassifications_single,  misclassifications_group