code: def numbered_syllable_to_accented(syllable):
      
      def keep_case_replace(s, vowel, replacement):
          accented = s.replace(vowel, replacement)
          if syllable[0].isupper():
              return accented[0].upper() + accented[1:]
          return accented
  
      tone = syllable[-1]
      if tone == '5':
          return re.sub('u:|v', '\u00fc', syllable[:-1])
      # Homogenise representation of u:
      syl = re.sub('u:|v', '\u00fc', syllable[:-1].lower())
      if 'a' in syl:
          return keep_case_replace(syl, 'a', _num_vowel_to_acc('a', tone))
      elif 'e' in syl:
          return keep_case_replace(syl, 'e', _num_vowel_to_acc('e', tone))
      elif 'ou' in syl:
          return keep_case_replace(syl, 'o', _num_vowel_to_acc('o', tone))
      last_vowel = syl[max(map(syl.rfind, VOWELS))]  # Find last vowel index.
      return keep_case_replace(syl, last_vowel, _num_vowel_to_acc(last_vowel, tone))
docs: Convert a numbered pinyin syllable to an accented pinyin syllable.
  
      Implements the following algorithm, modified from https://github.com/tsroten/zhon:
          1. If the syllable has an 'a' or 'e', put the tone over that vowel.
          2. If the syllable has 'ou', place the tone over the 'o'.
          3. Otherwise, put the tone on the last vowel.