class_docstr: Style token layer module.
  
  This module is style token layer 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:
      ref_embed_dim (int, optional): Dimension of the input reference embedding.
      gst_tokens (int, optional): The number of GST embeddings.
      gst_token_dim (int, optional): Dimension of each GST embedding.
      gst_heads (int, optional): The number of heads in GST multihead attention.
      dropout_rate (float, optional): Dropout rate in multi-head attention.
class_docstr_tok: ["Style","token","layer","module",".","This","module","is","style","token","layer","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",":","ref_embed_dim","(","int",",","optional",")",":","Dimension","of","the","input","reference","embedding",".","gst_tokens","(","int",",","optional",")",":","The","number","of","GST","embeddings",".","gst_token_dim","(","int",",","optional",")",":","Dimension","of","each","GST","embedding",".","gst_heads","(","int",",","optional",")",":","The","number","of","heads","in","GST","multihead","attention",".","dropout_rate","(","float",",","optional",")",":","Dropout","rate","in","multi-head","attention","."]
docstr: Initilize style token layer module.
docstr_tok: ["Initilize","style","token","layer","module","."]
code: def __init__(
      self,
      ref_embed_dim: int = 128,
      gst_tokens: int = 10,
      gst_token_dim: int = 256,
      gst_heads: int = 4,
      dropout_rate: float = 0.0,
  ):
      """Initilize style token layer module."""
      assert check_argument_types()
      super(StyleTokenLayer, self).__init__()
  
      gst_embs = torch.randn(gst_tokens, gst_token_dim // gst_heads)
      self.register_parameter("gst_embs", torch.nn.Parameter(gst_embs))
      self.mha = MultiHeadedAttention(
          q_dim=ref_embed_dim,
          k_dim=gst_token_dim // gst_heads,
          v_dim=gst_token_dim // gst_heads,
          n_head=gst_heads,
          n_feat=gst_token_dim,
          dropout_rate=dropout_rate,
      )
  
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 StyleTokenLayer object from inherited base classes: torch.nn with example: obj = StyleTokenLayer(ref_embed_dim, gst_tokens, gst_token_dim, gst_heads, dropout_rate)