class_docstr: Multi-Head Attention layer.
  
  Args:
      n_head (int): The number of heads.
      n_feat (int): The number of features.
      dropout_rate (float): Dropout rate.
class_docstr_tok: ["Multi-Head","Attention","layer",".","Args",":","n_head","(","int",")",":","The","number","of","heads",".","n_feat","(","int",")",":","The","number","of","features",".","dropout_rate","(","float",")",":","Dropout","rate","."]
docstr: Construct an MultiHeadedAttention object.
docstr_tok: ["Construct","an","MultiHeadedAttention","object","."]
code: def __init__(self, n_head, n_feat, dropout_rate):
      """Construct an MultiHeadedAttention object."""
      super(MultiHeadedAttention, self).__init__()
      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 = nn.Linear(n_feat, n_feat)
      self.linear_k = nn.Linear(n_feat, n_feat)
      self.linear_v = nn.Linear(n_feat, n_feat)
      self.linear_out = nn.Linear(n_feat, n_feat)
      self.attn = None
      self.dropout = nn.Dropout(p=dropout_rate)
  
file_path: espnet/espnet/nets/pytorch_backend/transformer/attention.py
imports: import math
  import torch
  from torch import nn
label_desc: Use image node_id 1 to create a new MultiHeadedAttention object from inherited base classes: nn with example: obj = MultiHeadedAttention(n_head, n_feat, dropout_rate)