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: Calculate forward propagation.
  
  Args:
      speech (Tensor): Batch of padded target features (B, Lmax, idim).
  
  Returns:
      Tensor: Reference embedding (B, gru_units)
docstr_tok: ["Calculate","forward","propagation",".","Args",":","speech","(","Tensor",")",":","Batch","of","padded","target","features","(","B",",","Lmax",",","idim",")",".","Returns",":","Tensor",":","Reference","embedding","(","B",",","gru_units",")"]
code: def forward(self, speech: torch.Tensor) -> torch.Tensor:
      """Calculate forward propagation.
  
      Args:
          speech (Tensor): Batch of padded target features (B, Lmax, idim).
  
      Returns:
          Tensor: Reference embedding (B, gru_units)
  
      """
      batch_size = speech.size(0)
      xs = speech.unsqueeze(1)  # (B, 1, Lmax, idim)
      hs = self.convs(xs).transpose(
          1, 2
      )  # (B, Lmax', conv_out_chans, idim')
      # NOTE(kan-bayashi): We need to care the length?
      time_length = hs.size(1)
      hs = hs.contiguous().view(
          batch_size, time_length, -1
      )  # (B, Lmax', gru_units)
      self.gru.flatten_parameters()
      _, ref_embs = self.gru(hs)  # (gru_layers, batch_size, gru_units)
      ref_embs = ref_embs[-1]  # (batch_size, gru_units)
  
      return ref_embs
  
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 2 for calling the ReferenceEncoder obj's underlying member method code with example usage: obj.forward(speech) and returns: ref_embs