class_docstr: Basic class for dataset. It operates as a map-style dataset, fetching
  data via :meth:`__getitem__` and :meth:`__len__` methods.
  
  .. note::
      This class subclasses :obj:`torch.utils.data.Dataset` and therefore can be treated as a regular PyTorch Dataset.
  
  Args:
      dataset (:obj:`list[tuple]`):
          A list of :obj:`(input, output)` pairs.
          If :obj:`input` consists of multiple fields (e.g. "premise" and "hypothesis" for SNLI),
          :obj:`input` must be of the form :obj:`(input_1, input_2, ...)` and :obj:`input_columns` parameter must be set.
          :obj:`output` can either be an integer representing labels for classification or a string for seq2seq tasks.
      input_columns (:obj:`list[str]`, `optional`, defaults to :obj:`["text"]`):
          List of column names of inputs in order.
      label_map (:obj:`dict[int, int]`, `optional`, defaults to :obj:`None`):
          Mapping if output labels of the dataset should be re-mapped. Useful if model was trained with a different label arrangement.
          For example, if dataset's arrangement is 0 for `Negative` and 1 for `Positive`, but model's label
          arrangement is 1 for `Negative` and 0 for `Positive`, passing :obj:`{0: 1, 1: 0}` will remap the dataset's label to match with model's arrangements.
          Could also be used to remap literal labels to numerical labels (e.g. :obj:`{"positive": 1, "negative": 0}`).
      label_names (:obj:`list[str]`, `optional`, defaults to :obj:`None`):
          List of label names in corresponding order (e.g. :obj:`["World", "Sports", "Business", "Sci/Tech"]` for AG-News dataset).
          If not set, labels will printed as is (e.g. "0", "1", ...). This should be set to :obj:`None` for non-classification datasets.
      output_scale_factor (:obj:`float`, `optional`, defaults to :obj:`None`):
          Factor to divide ground-truth outputs by. Generally, TextAttack goal functions require model outputs between 0 and 1.
          Some datasets are regression tasks, in which case this is necessary.
      shuffle (:obj:`bool`, `optional`, defaults to :obj:`False`): Whether to shuffle the underlying dataset.
  
          .. note::
              Generally not recommended to shuffle the underlying dataset. Shuffling can be performed using DataLoader or by shuffling the order of indices we attack.
  
  Examples::
  
      >>> import textattack
  
      >>> # Example of sentiment-classification dataset
      >>> data = [("I enjoyed the movie a lot!", 1), ("Absolutely horrible film.", 0), ("Our family had a fun time!", 1)]
      >>> dataset = textattack.datasets.Dataset(data)
      >>> dataset[1:2]
  
  
      >>> # Example for pair of sequence inputs (e.g. SNLI)
      >>> data = [("A man inspects the uniform of a figure in some East Asian country.", "The man is sleeping"), 1)]
      >>> dataset = textattack.datasets.Dataset(data, input_columns=("premise", "hypothesis"))
  
      >>> # Example for seq2seq
      >>> data = [("J'aime le film.", "I love the movie.")]
      >>> dataset = textattack.datasets.Dataset(data)
class_docstr_tok: ["Basic","class","for","dataset",".","It","operates","as","a","map-style","dataset",",","fetching","data","via",":","meth",":","`","__getitem__","`","and",":","meth",":","`","__len__","`","methods",".","..","note",":",":","This","class","subclasses",":","obj",":","`","torch.utils.data.Dataset","`","and","therefore","can","be","treated","as","a","regular","PyTorch","Dataset",".","Args",":","dataset","(",":","obj",":","`","list","[","tuple","]","`",")",":","A","list","of",":","obj",":","`","(","input",",","output",")","`","pairs",".","If",":","obj",":","`","input","`","consists","of","multiple","fields","(","e.g",".","``","premise","''","and","``","hypothesis","''","for","SNLI",")",",",":","obj",":","`","input","`","must","be","of","the","form",":","obj",":","`","(","input_1",",","input_2",",","...",")","`","and",":","obj",":","`","input_columns","`","parameter","must","be","set",".",":","obj",":","`","output","`","can","either","be","an","integer","representing","labels","for","classification","or","a","string","for","seq2seq","tasks",".","input_columns","(",":","obj",":","`","list","[","str","]","`",",","`","optional","`",",","defaults","to",":","obj",":","`","[","``","text","''","]","`",")",":","List","of","column","names","of","inputs","in","order",".","label_map","(",":","obj",":","`","dict","[","int",",","int","]","`",",","`","optional","`",",","defaults","to",":","obj",":","`","None","`",")",":","Mapping","if","output","labels","of","the","dataset","should","be","re-mapped",".","Useful","if","model","was","trained","with","a","different","label","arrangement",".","For","example",",","if","dataset","'s","arrangement","is","0","for","`","Negative","`","and","1","for","`","Positive","`",",","but","model","'s","label","arrangement","is","1","for","`","Negative","`","and","0","for","`","Positive","`",",","passing",":","obj",":","`","{","0",":","1",",","1",":","0","}","`","will","remap","the","dataset","'s","label","to","match","with","model","'s","arrangements",".","Could","also","be","used","to","remap","literal","labels","to","numerical","labels","(","e.g",".",":","obj",":","`","{","``","positive","''",":","1",",","``","negative","''",":","0","}","`",")",".","label_names","(",":","obj",":","`","list","[","str","]","`",",","`","optional","`",",","defaults","to",":","obj",":","`","None","`",")",":","List","of","label","names","in","corresponding","order","(","e.g",".",":","obj",":","`","[","``","World","''",",","``","Sports","''",",","``","Business","''",",","``","Sci\/Tech","''","]","`","for","AG-News","dataset",")",".","If","not","set",",","labels","will","printed","as","is","(","e.g",".","``","0","''",",","``","1","''",",","...",")",".","This","should","be","set","to",":","obj",":","`","None","`","for","non-classification","datasets",".","output_scale_factor","(",":","obj",":","`","float","`",",","`","optional","`",",","defaults","to",":","obj",":","`","None","`",")",":","Factor","to","divide","ground-truth","outputs","by",".","Generally",",","TextAttack","goal","functions","require","model","outputs","between","0","and","1",".","Some","datasets","are","regression","tasks",",","in","which","case","this","is","necessary",".","shuffle","(",":","obj",":","`","bool","`",",","`","optional","`",",","defaults","to",":","obj",":","`","False","`",")",":","Whether","to","shuffle","the","underlying","dataset",".","..","note",":",":","Generally","not","recommended","to","shuffle","the","underlying","dataset",".","Shuffling","can","be","performed","using","DataLoader","or","by","shuffling","the","order","of","indices","we","attack",".","Examples",":",":",">",">",">","import","textattack",">",">",">","#","Example","of","sentiment-classification","dataset",">",">",">","data","=","[","(","``","I","enjoyed","the","movie","a","lot","!","``",",","1",")",",","(","``","Absolutely","horrible","film",".","``",",","0",")",",","(","``","Our","family","had","a","fun","time","!","``",",","1",")","]",">",">",">","dataset","=","textattack.datasets.Dataset","(","data",")",">",">",">","dataset","[","1:2","]",">",">",">","#","Example","for","pair","of","sequence","inputs","(","e.g",".","SNLI",")",">",">",">","data","=","[","(","``","A","man","inspects","the","uniform","of","a","figure","in","some","East","Asian","country",".","``",",","``","The","man","is","sleeping","''",")",",","1",")","]",">",">",">","dataset","=","textattack.datasets.Dataset","(","data",",","input_columns=","(","``","premise","''",",","``","hypothesis","''",")",")",">",">",">","#","Example","for","seq2seq",">",">",">","data","=","[","(","``","J'aime","le","film",".","``",",","``","I","love","the","movie",".","''",")","]",">",">",">","dataset","=","textattack.datasets.Dataset","(","data",")"]
code: def __init__(
      self,
      dataset,
      input_columns=["text"],
      label_map=None,
      label_names=None,
      output_scale_factor=None,
      shuffle=False,
  ):
      self._dataset = dataset
      self.input_columns = input_columns
      self.label_map = label_map
      self.label_names = label_names
      if label_map:
          # If labels are remapped, the label names have to be remapped as well.
          self.label_names = [
              self.label_names[self.label_map[i]]
              for i in self.label_map
          ]
      self.shuffled = shuffle
      self.output_scale_factor = output_scale_factor
  
      if shuffle:
          random.shuffle(self._dataset)
  
file_path: TextAttack/textattack/datasets/dataset.py
imports: from collections import OrderedDict
  import random
  import torch
label_desc: Use image node_id 1 to create a new Dataset object from inherited base classes: torch.utils.data with example: obj = Dataset(dataset, input_columns, label_map, label_names, output_scale_factor, shuffle)