class_docstr: A ready-to-use wrapper for Fastspeech2 with internal alignment(text -> mel_spec).
  Arguments
  ---------
  hparams
      Hyperparameters (from HyperPyYAML)
  Example
  -------
  >>> tmpdir_tts = getfixture('tmpdir') / "tts"
  >>> fastspeech2 = FastSpeech2InternalAlignment.from_hparams(source="speechbrain/tts-fastspeech2-internal-alignment-ljspeech", savedir=tmpdir_tts) # doctest: +SKIP
  >>> mel_outputs, durations, pitch, energy = fastspeech2.encode_text(["Mary had a little lamb."]) # doctest: +SKIP
  >>> items = [
  ...   "A quick brown fox jumped over the lazy dog",
  ...   "How much wood would a woodchuck chuck?",
  ...   "Never odd or even"
  ... ]
  >>> mel_outputs, durations, pitch, energy = fastspeech2.encode_text(items) # doctest: +SKIP
  >>> # One can combine the TTS model with a vocoder (that generates the final waveform)
  >>> # Intialize the Vocoder (HiFIGAN)
  >>> tmpdir_vocoder = getfixture('tmpdir') / "vocoder"
  >>> from speechbrain.inference.vocoders import HIFIGAN
  >>> hifi_gan = HIFIGAN.from_hparams(source="speechbrain/tts-hifigan-ljspeech", savedir=tmpdir_vocoder) # doctest: +SKIP
  >>> # Running the TTS
  >>> mel_outputs, durations, pitch, energy = fastspeech2.encode_text(["Mary had a little lamb."]) # doctest: +SKIP
  >>> # Running Vocoder (spectrogram-to-waveform)
  >>> waveforms = hifi_gan.decode_batch(mel_outputs) # doctest: +SKIP
docstr: do grapheme to phoneme and keep the punctuations between the words
docstr_tok: ["do","grapheme","to","phoneme","and","keep","the","punctuations","between","the","words"]
code: def _g2p_keep_punctuations(self, g2p_model, text):
      """do grapheme to phoneme and keep the punctuations between the words"""
      # 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
  
imports: import re
  import logging
  import torch
  import torchaudio
  import random
  import speechbrain
  from speechbrain.utils.fetching import fetch
  from speechbrain.inference.interfaces import Pretrained
  from speechbrain.utils.text_to_sequence import text_to_sequence
  from speechbrain.inference.text import GraphemeToPhoneme
  from speechbrain.inference.encoders import MelSpectrogramEncoder
  from speechbrain.inference.classifiers import EncoderClassifier
label_desc: Use image node_id 3 for calling the FastSpeech2InternalAlignment obj's underlying member method code with example usage: obj._g2p_keep_punctuations(g2p_model, text) and returns: phonemes_with_punc