docstr: Generates attacked set of texts based off of original texts.
  
  :param texts: List of original strings
  :type texts: list
  :param text_sample_rate: P(individual text is attacked) if in [0, 1], else, number of attacks per text
  :type text_sample_rate: Union[int, float]
  :param word_sample_rate: P(word_i is sampled in a given word attack | word's text is sampled)
  :type word_sample_rate: float
  :param attacks: Description of attack configuration
  :type attacks: Union[str, list, dict]
  :param max_attacks: Maximum number of attacks that can be applied to a single text
  :type max_attacks: int
  :param random_seed: Seed for calls to random module functions
  :type random_seed: int
  :param save: Whether the generated texts should be pickled as output
  :type save: bool
  :return: List of tuples of generated strings in format (attacked text, list of attacks, index of original text)
  :rtype: list
docstr_tok: ["Generates","attacked","set","of","texts","based","off","of","original","texts",".",":","param","texts",":","List","of","original","strings",":","type","texts",":","list",":","param","text_sample_rate",":","P","(","individual","text","is","attacked",")","if","in","[","0",",","1","]",",","else",",","number","of","attacks","per","text",":","type","text_sample_rate",":","Union","[","int",",","float","]",":","param","word_sample_rate",":","P","(","word_i","is","sampled","in","a","given","word","attack","|","word","'s","text","is","sampled",")",":","type","word_sample_rate",":","float",":","param","attacks",":","Description","of","attack","configuration",":","type","attacks",":","Union","[","str",",","list",",","dict","]",":","param","max_attacks",":","Maximum","number","of","attacks","that","can","be","applied","to","a","single","text",":","type","max_attacks",":","int",":","param","random_seed",":","Seed","for","calls","to","random","module","functions",":","type","random_seed",":","int",":","param","save",":","Whether","the","generated","texts","should","be","pickled","as","output",":","type","save",":","bool",":","return",":","List","of","tuples","of","generated","strings","in","format","(","attacked","text",",","list","of","attacks",",","index","of","original","text",")",":","rtype",":","list"]
code: def generate(
      self,
      texts,
      text_sample_rate=1.0,
      word_sample_rate=0.3,
      attacks="all",
      max_attacks=2,
      random_seed=None,
      save=False,
  ):
      """
      Generates attacked set of texts based off of original texts.
  
      :param texts: List of original strings
      :type texts: list
      :param text_sample_rate: P(individual text is attacked) if in [0, 1], else, number of attacks per text
      :type text_sample_rate: Union[int, float]
      :param word_sample_rate: P(word_i is sampled in a given word attack | word's text is sampled)
      :type word_sample_rate: float
      :param attacks: Description of attack configuration
      :type attacks: Union[str, list, dict]
      :param max_attacks: Maximum number of attacks that can be applied to a single text
      :type max_attacks: int
      :param random_seed: Seed for calls to random module functions
      :type random_seed: int
      :param save: Whether the generated texts should be pickled as output
      :type save: bool
      :return: List of tuples of generated strings in format (attacked text, list of attacks, index of original text)
      :rtype: list
      """
      if random_seed:
          seed(random_seed)
  
      text_type = type(texts[0])
  
      text_attacks = list(ATTACK_MAP["text"].keys())
      word_attacks = list(ATTACK_MAP["word"].keys())
      config = self._read_config(attacks)
  
      if text_sample_rate > 1:
          num_iters = int(text_sample_rate)
      else:
          num_iters = 1
      total_num = num_iters * len(texts)
  
      # list of tuples containing (attacked text, list of attacks used, index of original text)
      generated = []
      original = copy(texts)
      for iter_no in range(num_iters):
          texts = copy(original)
          for i in range(len(texts)):
              if i % 100 == 0:
                  cur_num = iter_no * len(texts) + i
                  self.print_progress(
                      "Generating attacked version of string {} out of {}".format(
                          cur_num, total_num
                      )
                  )
              if text_sample_rate >= random():
                  num_attacks = 0
                  used_attacks = []
                  sorted_attacks = sorted(
                      [tuple(c) for c in config.items()],
                      key=lambda a: self._precendence(
                          a[0], word_attacks, text_attacks
                      ),
                  )
                  for attack, pr in sorted_attacks:
                      if pr >= random():
                          num_attacks += 1
                          if num_attacks > max_attacks:
                              break
                          used_attacks.append(attack)
                          if attack in text_attacks:
                              texts[i] = ATTACK_MAP["text"][attack](
                                  texts[i]
                              )
                          elif attack in word_attacks:
                              blob = TextBlob(texts[i]).tags
                              words_attacked = texts[i].split()
                              for j, word_with_tag in enumerate(blob):
                                  if (
                                      self._should_attack_word(
                                          word_with_tag[1]
                                      )
                                      and word_sample_rate >= random()
                                  ):
                                      try:
                                          words_attacked[
                                              j
                                          ] = ATTACK_MAP["word"][
                                              attack
                                          ](
                                              word_with_tag[0]
                                          )
                                      except IndexError:
                                          pass
                              texts[i] = " ".join(words_attacked)
                  generated.append(
                      (text_type(texts[i]), used_attacks, i)
                  )
              else:
                  generated.append((text_type(texts[i]), [], i))
  
      if save:
          pickle_to_file("generated_text.pkl", generated)
  
      return generated
  
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 2 for calling the Adversary obj's underlying member method code with example usage: obj.generate(texts, text_sample_rate, word_sample_rate, attacks, max_attacks, random_seed, save) and returns: generated