code: def augment_quotes(sents, ratio=0.15):
      """
      Go through the sentences and replace a fraction of sentences with alternate quotes
  
      TODO: for certain languages we may want to make some language-specific changes
        eg Danish, don't add «...»
      """
      assert len(START_QUOTES) == len(END_QUOTES)
  
      counts = Counter()
      new_sents = []
      for sent in sents:
          if random.random() > ratio:
              new_sents.append(sent)
              continue
  
          # count if there are exactly 2 quotes in this sentence
          # this is for convenience - otherwise we need to figure out which pairs go together
          count_quotes = sum(
              1
              for x in sent
              if (not x.startswith("#") and x.split("\t")[1] in QUOTES)
          )
          if count_quotes != 2:
              new_sents.append(sent)
              continue
  
          # choose a pair of quotes from the candidates
          quote_idx = random.choice(range(len(START_QUOTES)))
          start_quote = START_QUOTES[quote_idx]
          end_quote = END_QUOTES[quote_idx]
          counts[start_quote + end_quote] = (
              counts[start_quote + end_quote] + 1
          )
  
          new_sent = []
          saw_start = False
          for line in sent:
              if line.startswith("#"):
                  new_sent.append(line)
                  continue
              pieces = line.split("\t")
              if pieces[1] in QUOTES:
                  if saw_start:
                      # Note that we don't change the lemma.  Presumably it's
                      # set to the correct lemma for a quote for this treebank
                      pieces[1] = end_quote
                  else:
                      pieces[1] = start_quote
                      saw_start = True
                  new_sent.append("\t".join(pieces))
              else:
                  new_sent.append(line)
  
          for text_idx, text_line in enumerate(new_sent):
              # look for the line that starts with "# text".
              # keep going until we find it, or silently ignore it
              # if the dataset isn't in that format
              if text_line.startswith("# text"):
                  replacement = "\\1%s\\2%s\\3" % (
                      start_quote,
                      end_quote,
                  )
                  new_text_line = QUOTES_RE.sub(replacement, text_line)
                  new_sent[text_idx] = new_text_line
  
          new_sents.append(new_sent)
  
      print(
          "Augmented {} quotes: {}".format(sum(counts.values()), counts)
      )
      return new_sents
  
imports: import argparse
  import glob
  import os
  import random
  import re
  import tempfile
  from collections import Counter
  from stanza.models.common.constant import treebank_to_short_name
  import stanza.utils.datasets.common
  from stanza.utils.datasets.common import read_sentences_from_conllu, write_sentences_to_conllu, INT_RE, MWT_RE, MWT_OR_COPY_RE
  import stanza.utils.datasets.tokenization.convert_ml_cochin
  import stanza.utils.datasets.tokenization.convert_my_alt
  import stanza.utils.datasets.tokenization.convert_vi_vlsp
  import stanza.utils.datasets.tokenization.convert_th_best
  import stanza.utils.datasets.tokenization.convert_th_lst20
  import stanza.utils.datasets.tokenization.convert_th_orchid
label_desc: Use image node_id 13 for calling a global function with example usage: augment_quotes(sents, ratio) and returns: new_sents