class_docstr: A ready-to-use wrapper for Tacotron2 (text -> mel_spec).
  
  Arguments
  ---------
  hparams
      Hyperparameters (from HyperPyYAML)
  
  Example
  -------
  >>> tmpdir_tts = getfixture('tmpdir') / "tts"
  >>> tacotron2 = Tacotron2.from_hparams(source="speechbrain/tts-tacotron2-ljspeech", savedir=tmpdir_tts)
  >>> mel_output, mel_length, alignment = tacotron2.encode_text("Mary had a little lamb")
  >>> items = [
  ...   "A quick brown fox jumped over the lazy dog",
  ...   "How much wood would a woodchuck chuck?",
  ...   "Never odd or even"
  ... ]
  >>> mel_outputs, mel_lengths, alignments = tacotron2.encode_batch(items)
  
  >>> # 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)
  >>> # Running the TTS
  >>> mel_output, mel_length, alignment = tacotron2.encode_text("Mary had a little lamb")
  >>> # Running Vocoder (spectrogram-to-waveform)
  >>> waveforms = hifi_gan.decode_batch(mel_output)
docstr: Computes mel-spectrogram for a list of texts
  
  Texts must be sorted in decreasing order on their lengths
  
  Arguments
  ---------
  texts: List[str]
      texts to be encoded into spectrogram
  
  Returns
  -------
  tensors of output spectrograms, output lengths and alignments
docstr_tok: ["Computes","mel-spectrogram","for","a","list","of","texts","Texts","must","be","sorted","in","decreasing","order","on","their","lengths","Arguments","--","--","--","--","-","texts",":","List","[","str","]","texts","to","be","encoded","into","spectrogram","Returns","--","--","--","-","tensors","of","output","spectrograms",",","output","lengths","and","alignments"]
code: def encode_batch(self, texts):
      """Computes mel-spectrogram for a list of texts
  
      Texts must be sorted in decreasing order on their lengths
  
      Arguments
      ---------
      texts: List[str]
          texts to be encoded into spectrogram
  
      Returns
      -------
      tensors of output spectrograms, output lengths and alignments
      """
      with torch.no_grad():
          inputs = [
              {
                  "text_sequences": torch.tensor(
                      self.text_to_seq(item)[0], device=self.device
                  )
              }
              for item in texts
          ]
          inputs = speechbrain.dataio.batch.PaddedBatch(inputs)
  
          lens = [self.text_to_seq(item)[1] for item in texts]
          assert lens == sorted(
              lens, reverse=True
          ), "input lengths must be sorted in decreasing order"
          input_lengths = torch.tensor(lens, device=self.device)
  
          mel_outputs_postnet, mel_lengths, alignments = self.infer(
              inputs.text_sequences.data, input_lengths
          )
      return mel_outputs_postnet, mel_lengths, alignments
  
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 Tacotron2 obj's underlying member method code with example usage: obj.encode_batch(texts) and returns: mel_outputs_postnet,  mel_lengths,  alignments