docstr: :param data: Data for augmentation
  :param int n: Number of augmented output
  :param int num_thread: Number of thread for data augmentation. Use this option when you are using CPU and
      n is larger than 1
  :return: Augmented data
  
  >>> augmented_data = flow.augment(data)
docstr_tok: [":","param","data",":","Data","for","augmentation",":","param","int","n",":","Number","of","augmented","output",":","param","int","num_thread",":","Number","of","thread","for","data","augmentation",".","Use","this","option","when","you","are","using","CPU","and","n","is","larger","than","1",":","return",":","Augmented","data",">",">",">","augmented_data","=","flow.augment","(","data",")"]
code: def augment(self, data, n=1, num_thread=1):
      """
      :param data: Data for augmentation
      :param int n: Number of augmented output
      :param int num_thread: Number of thread for data augmentation. Use this option when you are using CPU and
          n is larger than 1
      :return: Augmented data
  
      >>> augmented_data = flow.augment(data)
      """
  
      max_retry_times = 3  # max loop times of n to generate expected number of outputs
      results = []
      is_duplicate_fx = self.get_is_duplicate_fx()
  
      for _ in range(max_retry_times + 1):
          augmented_results = []
          if num_thread == 1:
              augmented_results = [
                  self._augment(data) for _ in range(n)
              ]
          else:
              if self.device == "cpu":
                  augmented_results = self._parallel_augment(
                      self._augment, data, n=n, num_thread=num_thread
                  )
  
              # TODO: Externalize to util for checking
              elif "cuda" in self.device:
                  # TODO: support multiprocessing for GPU
                  # https://discuss.pytorch.org/t/using-cuda-multiprocessing-with-single-gpu/7300
                  augmented_results = [
                      self._augment(data) for _ in range(n)
                  ]
              else:
                  raise ValueError(
                      "Unsupported device mode [{}]. Only support `cpu` or `cuda`".format(
                          self.device
                      )
                  )
  
          # Flatten nested list
          augmented_results = [
              r
              for sub_results in augmented_results
              for r in sub_results
              if len(r) > 0
          ]
          for augmented_result in augmented_results:
              if is_duplicate_fx is not None and not is_duplicate_fx(
                  results + [data], augmented_result
              ):
                  results.extend(augmented_result)
  
              if len(results) >= n:
                  break
          if len(results) >= n:
              break
  
      if len(results) == 0:
          if len(data) == 0:
              return []
          return [data]
      return results[:n]
  
file_path: nlpaug/nlpaug/flow/pipeline.py
imports: from nlpaug import Augmenter
  from nlpaug.augmenter.char import CharAugmenter
  from nlpaug.util import Method
label_desc: Use image node_id 4 for calling the Pipeline obj's underlying member method code with example usage: obj.augment(data, n, num_thread) and returns: results, list, list