code: def _g2p_keep_punctuations(g2p_model, text):
      """do grapheme to phoneme and keep the punctuations between the words
      Arguments
      ---------
      g2p_model: speechbrain.inference.text g2p model
      text: string
          the input text
  
      Example
      -------
      >>> from speechbrain.inference.text import GraphemeToPhoneme
      >>> g2p_model = GraphemeToPhoneme.from_hparams("speechbrain/soundchoice-g2p") # doctest: +SKIP
      >>> from speechbrain.utils.text_to_sequence import _g2p_keep_punctuations # doctest: +SKIP
      >>> text = "Hi, how are you?" # doctest: +SKIP
      >>> _g2p_keep_punctuations(g2p_model, text) # doctest: +SKIP
      ['HH', 'AY', ',', ' ', 'HH', 'AW', ' ', 'AA', 'R', ' ', 'Y', 'UW', '?']
      """
      # find the words where a "-" or "'" or "." or ":" appears in the middle
      special_words = re.findall(r"\w+[-':\.][-':\.\w]*\w+", text)
  
      # remove intra-word punctuations ("-':."), this does not change the output of speechbrain g2p
      for special_word in special_words:
          rmp = special_word.replace("-", "")
          rmp = rmp.replace("'", "")
          rmp = rmp.replace(":", "")
          rmp = rmp.replace(".", "")
          text = text.replace(special_word, rmp)
  
      # keep inter-word punctuations
      all_ = re.findall(r"[\w]+|[-!'(),.:;? ]", text)
      try:
          phonemes = g2p_model(text)
      except RuntimeError:
          logger.info(f"error with text: {text}")
          quit()
      word_phonemes = "-".join(phonemes).split(" ")
  
      phonemes_with_punc = []
      count = 0
      try:
          # if the g2p model splits the words correctly
          for i in all_:
              if i not in "-!'(),.:;? ":
                  phonemes_with_punc.extend(
                      word_phonemes[count].split("-")
                  )
                  count += 1
              else:
                  phonemes_with_punc.append(i)
      except IndexError:
          # sometimes the g2p model cannot split the words correctly
          logger.warning(
              f"Do g2p word by word because of unexpected ouputs from g2p for text: {text}"
          )
  
          for i in all_:
              if i not in "-!'(),.:;? ":
                  p = g2p_model.g2p(i)
                  p_without_space = [i for i in p if i != " "]
                  phonemes_with_punc.extend(p_without_space)
              else:
                  phonemes_with_punc.append(i)
  
      while "" in phonemes_with_punc:
          phonemes_with_punc.remove("")
      return phonemes_with_punc
  
file_path: speechbrain/speechbrain/utils/text_to_sequence.py
imports: import re
  import logging
label_desc: Use image node_id 15 for calling a global function with example usage: _g2p_keep_punctuations(g2p_model, text) and returns: phonemes_with_punc