class_docstr: Randomly apply one or many data augmentation transforms to spaCy ``Doc`` s
  to produce new docs with additional variety and/or noise in the data.
  
  Initialize an ``Augmenter`` with multiple transforms, and customize the randomization
  of their selection when applying to a document::
  
      >>> tfs = [transforms.delete_words, transforms.swap_chars, transforms.delete_chars]
      >>> Augmenter(tfs, num=None)  # all tfs applied each time
      >>> Augmenter(tfs, num=1)  # one randomly-selected tf applied each time
      >>> Augmenter(tfs, num=0.5)  # tfs randomly selected with 50% prob each time
      >>> augmenter = Augmenter(tfs, num=[0.4, 0.8, 0.6])  # tfs randomly selected with 40%, 80%, 60% probs, respectively, each time
  
  Apply transforms to a given ``Doc`` to produce new documents::
  
      >>> text = "The quick brown fox jumps over the lazy dog."
      >>> doc = textacy.make_spacy_doc(text, lang="en_core_web_sm")
      >>> augmenter.apply_transforms(doc, lang="en_core_web_sm")
      The quick brown ox jupms over the lazy dog.
      >>> augmenter.apply_transforms(doc, lang="en_core_web_sm")
      The quikc brown fox over the lazy dog.
      >>> augmenter.apply_transforms(doc, lang="en_core_web_sm")
      quick brown fox jumps over teh lazy dog.
  
  Parameters for individual transforms may be specified when initializing ``Augmenter``
  or, if necessary, when applying to individual documents::
  
      >>> from functools import partial
      >>> tfs = [partial(transforms.delete_words, num=3), transforms.swap_chars]
      >>> augmenter = Augmenter(tfs)
      >>> augmenter.apply_transforms(doc, lang="en_core_web_sm")
      brown fox jumps over layz dog.
      >>> augmenter.apply_transforms(doc, lang="en_core_web_sm", pos={"NOUN", "ADJ"})
      The jumps over the lazy odg.
  
  Args:
      transforms: Ordered sequence of callables that must take list[:obj:`AugTok`]
          as their first positional argument and return another list[:obj:`AugTok`].
  
          .. note:: Although the particular transforms applied may vary doc-by-doc,
             they are applied *in order* as listed here. Since some transforms may
             clobber text in a way that makes other transforms less effective,
             a stable ordering can improve the quality of augmented data.
  
      num: If int, number of transforms to randomly select from ``transforms`` each time
          :meth:`Augmenter.apply_tranforms()` is called.
          If float, probability that any given transform will be selected.
          If Sequence[float], the probability that the corresponding transform
          in ``transforms`` will be selected (these must be the same length).
          If None (default), num is set to ``len(transforms)``, which means that
          every transform is applied each time.
  
  See Also:
      A collection of general-purpose transforms are implemented in
      :mod:`textacy.augmentation.transforms`.
class_docstr_tok: ["Randomly","apply","one","or","many","data","augmentation","transforms","to","spaCy","``","Doc","``","s","to","produce","new","docs","with","additional","variety","and\/or","noise","in","the","data",".","Initialize","an","``","Augmenter","``","with","multiple","transforms",",","and","customize","the","randomization","of","their","selection","when","applying","to","a","document",":",":",">",">",">","tfs","=","[","transforms.delete_words",",","transforms.swap_chars",",","transforms.delete_chars","]",">",">",">","Augmenter","(","tfs",",","num=None",")","#","all","tfs","applied","each","time",">",">",">","Augmenter","(","tfs",",","num=1",")","#","one","randomly-selected","tf","applied","each","time",">",">",">","Augmenter","(","tfs",",","num=0.5",")","#","tfs","randomly","selected","with","50","%","prob","each","time",">",">",">","augmenter","=","Augmenter","(","tfs",",","num=","[","0.4",",","0.8",",","0.6","]",")","#","tfs","randomly","selected","with","40","%",",","80","%",",","60","%","probs",",","respectively",",","each","time","Apply","transforms","to","a","given","``","Doc","``","to","produce","new","documents",":",":",">",">",">","text","=","``","The","quick","brown","fox","jumps","over","the","lazy","dog",".","''",">",">",">","doc","=","textacy.make_spacy_doc","(","text",",","lang=","''","en_core_web_sm","''",")",">",">",">","augmenter.apply_transforms","(","doc",",","lang=","''","en_core_web_sm","''",")","The","quick","brown","ox","jupms","over","the","lazy","dog",".",">",">",">","augmenter.apply_transforms","(","doc",",","lang=","''","en_core_web_sm","''",")","The","quikc","brown","fox","over","the","lazy","dog",".",">",">",">","augmenter.apply_transforms","(","doc",",","lang=","''","en_core_web_sm","''",")","quick","brown","fox","jumps","over","teh","lazy","dog",".","Parameters","for","individual","transforms","may","be","specified","when","initializing","``","Augmenter","``","or",",","if","necessary",",","when","applying","to","individual","documents",":",":",">",">",">","from","functools","import","partial",">",">",">","tfs","=","[","partial","(","transforms.delete_words",",","num=3",")",",","transforms.swap_chars","]",">",">",">","augmenter","=","Augmenter","(","tfs",")",">",">",">","augmenter.apply_transforms","(","doc",",","lang=","''","en_core_web_sm","''",")","brown","fox","jumps","over","layz","dog",".",">",">",">","augmenter.apply_transforms","(","doc",",","lang=","''","en_core_web_sm","''",",","pos=","{","``","NOUN","''",",","``","ADJ","''","}",")","The","jumps","over","the","lazy","odg",".","Args",":","transforms",":","Ordered","sequence","of","callables","that","must","take","list","[",":","obj",":","`","AugTok","`","]","as","their","first","positional","argument","and","return","another","list","[",":","obj",":","`","AugTok","`","]",".","..","note",":",":","Although","the","particular","transforms","applied","may","vary","doc-by-doc",",","they","are","applied","*","in","order","*","as","listed","here",".","Since","some","transforms","may","clobber","text","in","a","way","that","makes","other","transforms","less","effective",",","a","stable","ordering","can","improve","the","quality","of","augmented","data",".","num",":","If","int",",","number","of","transforms","to","randomly","select","from","``","transforms","``","each","time",":","meth",":","`","Augmenter.apply_tranforms","(",")","`","is","called",".","If","float",",","probability","that","any","given","transform","will","be","selected",".","If","Sequence","[","float","]",",","the","probability","that","the","corresponding","transform","in","``","transforms","``","will","be","selected","(","these","must","be","the","same","length",")",".","If","None","(","default",")",",","num","is","set","to","``","len","(","transforms",")","``",",","which","means","that","every","transform","is","applied","each","time",".","See","Also",":","A","collection","of","general-purpose","transforms","are","implemented","in",":","mod",":","`","textacy.augmentation.transforms","`","."]
docstr: Sequentially apply some subset of data augmentation transforms to ``doc``,
  then return a new ``Doc`` created from the augmented text using ``lang``.
  
  Args:
      doc
      lang
      **kwargs: If, for whatever reason, you have to pass keyword argument values
          into transforms that vary or depend on characteristics of ``doc``,
          specify them here. The transforms' call signatures will be inspected,
          and values will be passed along, as needed.
  
  Returns:
      :class:`spacy.tokens.Doc`
docstr_tok: ["Sequentially","apply","some","subset","of","data","augmentation","transforms","to","``","doc","``",",","then","return","a","new","``","Doc","``","created","from","the","augmented","text","using","``","lang","``",".","Args",":","doc","lang","*","*","kwargs",":","If",",","for","whatever","reason",",","you","have","to","pass","keyword","argument","values","into","transforms","that","vary","or","depend","on","characteristics","of","``","doc","``",",","specify","them","here",".","The","transforms","'","call","signatures","will","be","inspected",",","and","values","will","be","passed","along",",","as","needed",".","Returns",":",":","class",":","`","spacy.tokens.Doc","`"]
code: def apply_transforms(
      self, doc: Doc, lang: types.LangLike, **kwargs
  ) -> Doc:
      """
      Sequentially apply some subset of data augmentation transforms to ``doc``,
      then return a new ``Doc`` created from the augmented text using ``lang``.
  
      Args:
          doc
          lang
          **kwargs: If, for whatever reason, you have to pass keyword argument values
              into transforms that vary or depend on characteristics of ``doc``,
              specify them here. The transforms' call signatures will be inspected,
              and values will be passed along, as needed.
  
      Returns:
          :class:`spacy.tokens.Doc`
      """
      if doc.has_annotation("SENT_START"):
          nested_aug_toks = [
              aug_utils.to_aug_toks(sent) for sent in doc.sents
          ]
      else:
          nested_aug_toks = [aug_utils.to_aug_toks(doc)]
      tfs = self._get_random_transforms()
      new_nested_aug_toks = []
      for aug_toks in nested_aug_toks:
          # this is a bit of a hack, but whatchagonnado
          if kwargs:
              for tf in tfs:
                  tf_kwargs = utils.get_kwargs_for_func(tf, kwargs)
                  aug_toks = tf(aug_toks, **tf_kwargs)
          else:
              for tf in tfs:
                  aug_toks = tf(aug_toks)
          new_nested_aug_toks.append(aug_toks)
      return self._make_new_spacy_doc(new_nested_aug_toks, lang)
  
file_path: textacy/src/textacy/augmentation/augmenter.py
imports: from __future__ import annotations
  import random
  from typing import Optional, Sequence
  from spacy.tokens import Doc
  from ..None import spacier, types, utils
  from .None import utils
label_desc: Use image node_id 2 for calling the Augmenter obj's underlying member method code with example usage: obj.apply_transforms(doc, lang) and returns: self