class_docstr: Tacotron2 model from *Natural TTS Synthesis by Conditioning WaveNet on Mel Spectrogram Predictions*
  :cite:`shen2018natural` based on the implementation from
  `Nvidia Deep Learning Examples <https://github.com/NVIDIA/DeepLearningExamples/>`_.
  
  See Also:
      * :class:`torchaudio.pipelines.Tacotron2TTSBundle`: TTS pipeline with pretrained model.
  
  Args:
      mask_padding (bool, optional): Use mask padding (Default: ``False``).
      n_mels (int, optional): Number of mel bins (Default: ``80``).
      n_symbol (int, optional): Number of symbols for the input text (Default: ``148``).
      n_frames_per_step (int, optional): Number of frames processed per step, only 1 is supported (Default: ``1``).
      symbol_embedding_dim (int, optional): Input embedding dimension (Default: ``512``).
      encoder_n_convolution (int, optional): Number of encoder convolutions (Default: ``3``).
      encoder_kernel_size (int, optional): Encoder kernel size (Default: ``5``).
      encoder_embedding_dim (int, optional): Encoder embedding dimension (Default: ``512``).
      decoder_rnn_dim (int, optional): Number of units in decoder LSTM (Default: ``1024``).
      decoder_max_step (int, optional): Maximum number of output mel spectrograms (Default: ``2000``).
      decoder_dropout (float, optional): Dropout probability for decoder LSTM (Default: ``0.1``).
      decoder_early_stopping (bool, optional): Continue decoding after all samples are finished (Default: ``True``).
      attention_rnn_dim (int, optional): Number of units in attention LSTM (Default: ``1024``).
      attention_hidden_dim (int, optional): Dimension of attention hidden representation (Default: ``128``).
      attention_location_n_filter (int, optional): Number of filters for attention model (Default: ``32``).
      attention_location_kernel_size (int, optional): Kernel size for attention model (Default: ``31``).
      attention_dropout (float, optional): Dropout probability for attention LSTM (Default: ``0.1``).
      prenet_dim (int, optional): Number of ReLU units in prenet layers (Default: ``256``).
      postnet_n_convolution (int, optional): Number of postnet convolutions (Default: ``5``).
      postnet_kernel_size (int, optional): Postnet kernel size (Default: ``5``).
      postnet_embedding_dim (int, optional): Postnet embedding dimension (Default: ``512``).
      gate_threshold (float, optional): Probability threshold for stop token (Default: ``0.5``).
class_docstr_tok: ["Tacotron2","model","from","*","Natural","TTS","Synthesis","by","Conditioning","WaveNet","on","Mel","Spectrogram","Predictions","*",":","cite",":","`","shen2018natural","`","based","on","the","implementation","from","`","Nvidia","Deep","Learning","Examples","<","https",":","\/\/github.com\/NVIDIA\/DeepLearningExamples\/",">","`","_",".","See","Also",":","*",":","class",":","`","torchaudio.pipelines.Tacotron2TTSBundle","`",":","TTS","pipeline","with","pretrained","model",".","Args",":","mask_padding","(","bool",",","optional",")",":","Use","mask","padding","(","Default",":","``","False","``",")",".","n_mels","(","int",",","optional",")",":","Number","of","mel","bins","(","Default",":","``","80","``",")",".","n_symbol","(","int",",","optional",")",":","Number","of","symbols","for","the","input","text","(","Default",":","``","148","``",")",".","n_frames_per_step","(","int",",","optional",")",":","Number","of","frames","processed","per","step",",","only","1","is","supported","(","Default",":","``","1","``",")",".","symbol_embedding_dim","(","int",",","optional",")",":","Input","embedding","dimension","(","Default",":","``","512","``",")",".","encoder_n_convolution","(","int",",","optional",")",":","Number","of","encoder","convolutions","(","Default",":","``","3","``",")",".","encoder_kernel_size","(","int",",","optional",")",":","Encoder","kernel","size","(","Default",":","``","5","``",")",".","encoder_embedding_dim","(","int",",","optional",")",":","Encoder","embedding","dimension","(","Default",":","``","512","``",")",".","decoder_rnn_dim","(","int",",","optional",")",":","Number","of","units","in","decoder","LSTM","(","Default",":","``","1024","``",")",".","decoder_max_step","(","int",",","optional",")",":","Maximum","number","of","output","mel","spectrograms","(","Default",":","``","2000","``",")",".","decoder_dropout","(","float",",","optional",")",":","Dropout","probability","for","decoder","LSTM","(","Default",":","``","0.1","``",")",".","decoder_early_stopping","(","bool",",","optional",")",":","Continue","decoding","after","all","samples","are","finished","(","Default",":","``","True","``",")",".","attention_rnn_dim","(","int",",","optional",")",":","Number","of","units","in","attention","LSTM","(","Default",":","``","1024","``",")",".","attention_hidden_dim","(","int",",","optional",")",":","Dimension","of","attention","hidden","representation","(","Default",":","``","128","``",")",".","attention_location_n_filter","(","int",",","optional",")",":","Number","of","filters","for","attention","model","(","Default",":","``","32","``",")",".","attention_location_kernel_size","(","int",",","optional",")",":","Kernel","size","for","attention","model","(","Default",":","``","31","``",")",".","attention_dropout","(","float",",","optional",")",":","Dropout","probability","for","attention","LSTM","(","Default",":","``","0.1","``",")",".","prenet_dim","(","int",",","optional",")",":","Number","of","ReLU","units","in","prenet","layers","(","Default",":","``","256","``",")",".","postnet_n_convolution","(","int",",","optional",")",":","Number","of","postnet","convolutions","(","Default",":","``","5","``",")",".","postnet_kernel_size","(","int",",","optional",")",":","Postnet","kernel","size","(","Default",":","``","5","``",")",".","postnet_embedding_dim","(","int",",","optional",")",":","Postnet","embedding","dimension","(","Default",":","``","512","``",")",".","gate_threshold","(","float",",","optional",")",":","Probability","threshold","for","stop","token","(","Default",":","``","0.5","``",")","."]
code: def __init__(
      self,
      mask_padding: bool = False,
      n_mels: int = 80,
      n_symbol: int = 148,
      n_frames_per_step: int = 1,
      symbol_embedding_dim: int = 512,
      encoder_embedding_dim: int = 512,
      encoder_n_convolution: int = 3,
      encoder_kernel_size: int = 5,
      decoder_rnn_dim: int = 1024,
      decoder_max_step: int = 2000,
      decoder_dropout: float = 0.1,
      decoder_early_stopping: bool = True,
      attention_rnn_dim: int = 1024,
      attention_hidden_dim: int = 128,
      attention_location_n_filter: int = 32,
      attention_location_kernel_size: int = 31,
      attention_dropout: float = 0.1,
      prenet_dim: int = 256,
      postnet_n_convolution: int = 5,
      postnet_kernel_size: int = 5,
      postnet_embedding_dim: int = 512,
      gate_threshold: float = 0.5,
  ) -> None:
      super().__init__()
  
      self.mask_padding = mask_padding
      self.n_mels = n_mels
      self.n_frames_per_step = n_frames_per_step
      self.embedding = nn.Embedding(n_symbol, symbol_embedding_dim)
      torch.nn.init.xavier_uniform_(self.embedding.weight)
      self.encoder = _Encoder(
          encoder_embedding_dim,
          encoder_n_convolution,
          encoder_kernel_size,
      )
      self.decoder = _Decoder(
          n_mels,
          n_frames_per_step,
          encoder_embedding_dim,
          decoder_rnn_dim,
          decoder_max_step,
          decoder_dropout,
          decoder_early_stopping,
          attention_rnn_dim,
          attention_hidden_dim,
          attention_location_n_filter,
          attention_location_kernel_size,
          attention_dropout,
          prenet_dim,
          gate_threshold,
      )
      self.postnet = _Postnet(
          n_mels,
          postnet_embedding_dim,
          postnet_kernel_size,
          postnet_n_convolution,
      )
  
imports: import warnings
  from typing import List, Optional, Tuple, Union
  import torch
  from torch import nn, Tensor
  from torch.nn import functional
label_desc: Use image node_id 1 to create a new Tacotron2 object from inherited base classes: nn with example: obj = Tacotron2(mask_padding, n_mels, n_symbol, n_frames_per_step, symbol_embedding_dim, encoder_embedding_dim, encoder_n_convolution, encoder_kernel_size, decoder_rnn_dim, decoder_max_step, decoder_dropout, decoder_early_stopping, attention_rnn_dim, attention_hidden_dim, attention_location_n_filter, attention_location_kernel_size, attention_dropout, prenet_dim, postnet_n_convolution, postnet_kernel_size, postnet_embedding_dim, gate_threshold)