class_docstr: Multi head attention module with different input dimension.
class_docstr_tok: ["Multi","head","attention","module","with","different","input","dimension","."]
docstr: Initialize multi head attention module.
docstr_tok: ["Initialize","multi","head","attention","module","."]
code: def __init__(
      self, q_dim, k_dim, v_dim, n_head, n_feat, dropout_rate=0.0
  ):
      """Initialize multi head attention module."""
      # NOTE(kan-bayashi): Do not use super().__init__() here since we want to
      #   overwrite BaseMultiHeadedAttention.__init__() method.
      torch.nn.Module.__init__(self)
      assert n_feat % n_head == 0
      # We assume d_v always equals d_k
      self.d_k = n_feat // n_head
      self.h = n_head
      self.linear_q = torch.nn.Linear(q_dim, n_feat)
      self.linear_k = torch.nn.Linear(k_dim, n_feat)
      self.linear_v = torch.nn.Linear(v_dim, n_feat)
      self.linear_out = torch.nn.Linear(n_feat, n_feat)
      self.attn = None
      self.dropout = torch.nn.Dropout(p=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 MultiHeadedAttention object from inherited base classes: BaseMultiHeadedAttention with example: obj = MultiHeadedAttention(q_dim, k_dim, v_dim, n_head, n_feat, dropout_rate)