class_docstr: An attack generates adversarial examples on text.
  
  This is an abstract class that contains main helper functionality for
  attacks. An attack is comprised of a search method, goal function,
  a transformation, and a set of one or more linguistic constraints that
  successful examples must meet.
class_docstr_tok: ["An","attack","generates","adversarial","examples","on","text",".","This","is","an","abstract","class","that","contains","main","helper","functionality","for","attacks",".","An","attack","is","comprised","of","a","search","method",",","goal","function",",","a","transformation",",","and","a","set","of","one","or","more","linguistic","constraints","that","successful","examples","must","meet","."]
docstr: Gets examples from a dataset and tokenizes them.
  
  :param dataset: An iterable of (text_input, ground_truth_output) pairs
  :param indices: An iterable of indices of the dataset that we want to
      attack. If None, attack all samples in dataset.
  :return: results (Iterable[GoalFunctionResult]): an iterable of
      GoalFunctionResults of the original examples
docstr_tok: ["Gets","examples","from","a","dataset","and","tokenizes","them",".",":","param","dataset",":","An","iterable","of","(","text_input",",","ground_truth_output",")","pairs",":","param","indices",":","An","iterable","of","indices","of","the","dataset","that","we","want","to","attack",".","If","None",",","attack","all","samples","in","dataset",".",":","return",":","results","(","Iterable","[","GoalFunctionResult","]",")",":","an","iterable","of","GoalFunctionResults","of","the","original","examples"]
code: def _get_examples_from_dataset(self, dataset, indices=None):
      """
      Gets examples from a dataset and tokenizes them.
  
      :param dataset: An iterable of (text_input, ground_truth_output) pairs
      :param indices: An iterable of indices of the dataset that we want to
          attack. If None, attack all samples in dataset.
      :return: results (Iterable[GoalFunctionResult]): an iterable of
          GoalFunctionResults of the original examples
      """
      if indices is None:
          indices = range(len(dataset))
  
      if not isinstance(indices, deque):
          indices = deque(sorted(indices))
  
      if not indices:
          return
  
      while indices:
          i = indices.popleft()
          try:
              text_input, ground_truth_str = dataset[i].to_tuple()
              ground_truth_output = self.goal_function.model.label2id[
                  ground_truth_str
              ]
          except IndexError:
              utils.logger.warn(
                  f"Dataset has {len(dataset)} samples but tried to access "
                  f"index {i}. Ending attack early."
              )
              break
  
          try:
              # get label names from dataset, if possible
              label_names = dataset.label_names
          except AttributeError:
              label_names = None
          attacked_text = AttackedText(
              text_input, attack_attrs={"label_names": label_names}
          )
          (
              goal_function_result,
              _,
          ) = self.goal_function.init_attack_example(
              attacked_text, ground_truth_output
          )
          yield dataset[i], goal_function_result
  
imports: import lru
  from collections import deque
  from ...common import logger
  from textattack.attack_results import FailedAttackResult, MaximizedAttackResult, SuccessfulAttackResult
  from textattack.goal_function_results import GoalFunctionResultStatus
  from textattack.shared import AttackedText, utils
  from textattack.transformations import CompositeTransformation
label_desc: Use image node_id 9 for calling the Attack obj's underlying member method code with example usage: obj._get_examples_from_dataset(dataset, indices) without return types