class_docstr: Reference encoder module.
  
  This module is reference encoder introduced in `Style Tokens: Unsupervised Style
  Modeling, Control and Transfer in End-to-End Speech Synthesis`.
  
  .. _`Style Tokens: Unsupervised Style Modeling, Control and Transfer in End-to-End
      Speech Synthesis`: https://arxiv.org/abs/1803.09017
  
  Args:
      idim (int, optional): Dimension of the input mel-spectrogram.
      conv_layers (int, optional): The number of conv layers in the reference encoder.
      conv_chans_list: (Sequence[int], optional):
          List of the number of channels of conv layers in the referece encoder.
      conv_kernel_size (int, optional):
          Kernel size of conv layers in the reference encoder.
      conv_stride (int, optional):
          Stride size of conv layers in the reference encoder.
      gru_layers (int, optional): The number of GRU layers in the reference encoder.
      gru_units (int, optional): The number of GRU units in the reference encoder.
class_docstr_tok: ["Reference","encoder","module",".","This","module","is","reference","encoder","introduced","in","`","Style","Tokens",":","Unsupervised","Style","Modeling",",","Control","and","Transfer","in","End-to-End","Speech","Synthesis","`",".","..","_","`","Style","Tokens",":","Unsupervised","Style","Modeling",",","Control","and","Transfer","in","End-to-End","Speech","Synthesis","`",":","https",":","\/\/arxiv.org\/abs\/1803.09017","Args",":","idim","(","int",",","optional",")",":","Dimension","of","the","input","mel-spectrogram",".","conv_layers","(","int",",","optional",")",":","The","number","of","conv","layers","in","the","reference","encoder",".","conv_chans_list",":","(","Sequence","[","int","]",",","optional",")",":","List","of","the","number","of","channels","of","conv","layers","in","the","referece","encoder",".","conv_kernel_size","(","int",",","optional",")",":","Kernel","size","of","conv","layers","in","the","reference","encoder",".","conv_stride","(","int",",","optional",")",":","Stride","size","of","conv","layers","in","the","reference","encoder",".","gru_layers","(","int",",","optional",")",":","The","number","of","GRU","layers","in","the","reference","encoder",".","gru_units","(","int",",","optional",")",":","The","number","of","GRU","units","in","the","reference","encoder","."]
docstr: Initilize reference encoder module.
docstr_tok: ["Initilize","reference","encoder","module","."]
code: def __init__(
      self,
      idim=80,
      conv_layers: int = 6,
      conv_chans_list: Sequence[int] = (32, 32, 64, 64, 128, 128),
      conv_kernel_size: int = 3,
      conv_stride: int = 2,
      gru_layers: int = 1,
      gru_units: int = 128,
  ):
      """Initilize reference encoder module."""
      assert check_argument_types()
      super(ReferenceEncoder, self).__init__()
  
      # check hyperparameters are valid
      assert conv_kernel_size % 2 == 1, "kernel size must be odd."
      assert (
          len(conv_chans_list) == conv_layers
      ), "the number of conv layers and length of channels list must be the same."
  
      convs = []
      padding = (conv_kernel_size - 1) // 2
      for i in range(conv_layers):
          conv_in_chans = 1 if i == 0 else conv_chans_list[i - 1]
          conv_out_chans = conv_chans_list[i]
          convs += [
              torch.nn.Conv2d(
                  conv_in_chans,
                  conv_out_chans,
                  kernel_size=conv_kernel_size,
                  stride=conv_stride,
                  padding=padding,
                  # Do not use bias due to the following batch norm
                  bias=False,
              ),
              torch.nn.BatchNorm2d(conv_out_chans),
              torch.nn.ReLU(inplace=True),
          ]
      self.convs = torch.nn.Sequential(*convs)
  
      self.conv_layers = conv_layers
      self.kernel_size = conv_kernel_size
      self.stride = conv_stride
      self.padding = padding
  
      # get the number of GRU input units
      gru_in_units = idim
      for i in range(conv_layers):
          gru_in_units = (
              gru_in_units - conv_kernel_size + 2 * padding
          ) // conv_stride + 1
      gru_in_units *= conv_out_chans
      self.gru = torch.nn.GRU(
          gru_in_units, gru_units, gru_layers, batch_first=True
      )
  
file_path: espnet/espnet2/tts/gst/style_encoder.py
imports: from typing import Sequence
  import torch
  from typeguard import check_argument_types
  from espnet.nets.pytorch_backend.transformer.attention import MultiHeadedAttention
label_desc: Use image node_id 1 to create a new ReferenceEncoder object from inherited base classes: torch.nn with example: obj = ReferenceEncoder(idim, conv_layers, conv_chans_list, conv_kernel_size, conv_stride, gru_layers, gru_units)