class_docstr: Multi-Head Attention layer of Transformer.
  Args:
      n_head (int): number of heads
      n_feat (int): size of the features
      dropout_rate (float): dropout rate
class_docstr_tok: ["Multi-Head","Attention","layer","of","Transformer",".","Args",":","n_head","(","int",")",":","number","of","heads","n_feat","(","int",")",":","size","of","the","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, max_cache_len=0):
      """Construct an MultiHeadedAttention object."""
      super(MultiHeadAttention, self).__init__()
      self.cache_drop_size = None
      assert n_feat % n_head == 0
      # We assume d_v always equals d_k
      self.d_k = n_feat // n_head
      self.s_d_k = math.sqrt(self.d_k)
      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.dropout = nn.Dropout(p=dropout_rate)
  
      self._max_cache_len = max_cache_len
  
imports: import math
  from functools import lru_cache
  from typing import List, Tuple
  import torch
  import torch.nn
  import torch.nn.functional
  from nemo.utils import avoid_float16_autocast_context
label_desc: Use image node_id 1 to create a new MultiHeadAttention object from inherited base classes: nn with example: obj = MultiHeadAttention(n_head, n_feat, dropout_rate, max_cache_len)