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: Compute scaled dot product attention.
  
  Args:
      query (torch.Tensor): Query tensor (#batch, time1, size).
      key (torch.Tensor): Key tensor (#batch, time2, size).
      value (torch.Tensor): Value tensor (#batch, time2, size).
      mask (torch.Tensor): Mask tensor (#batch, 1, time2) or
          (#batch, time1, time2).
  
  Returns:
      torch.Tensor: Output tensor (#batch, time1, d_model).
docstr_tok: ["Compute","scaled","dot","product","attention",".","Args",":","query","(","torch.Tensor",")",":","Query","tensor","(","#","batch",",","time1",",","size",")",".","key","(","torch.Tensor",")",":","Key","tensor","(","#","batch",",","time2",",","size",")",".","value","(","torch.Tensor",")",":","Value","tensor","(","#","batch",",","time2",",","size",")",".","mask","(","torch.Tensor",")",":","Mask","tensor","(","#","batch",",","1",",","time2",")","or","(","#","batch",",","time1",",","time2",")",".","Returns",":","torch.Tensor",":","Output","tensor","(","#","batch",",","time1",",","d_model",")","."]
code: def forward(self, query, key, value, mask):
      """Compute scaled dot product attention.
  
      Args:
          query (torch.Tensor): Query tensor (#batch, time1, size).
          key (torch.Tensor): Key tensor (#batch, time2, size).
          value (torch.Tensor): Value tensor (#batch, time2, size).
          mask (torch.Tensor): Mask tensor (#batch, 1, time2) or
              (#batch, time1, time2).
  
      Returns:
          torch.Tensor: Output tensor (#batch, time1, d_model).
  
      """
      q, k, v = self.forward_qkv(query, key, value)
      scores = torch.matmul(q, k.transpose(-2, -1)) / math.sqrt(
          self.d_k
      )
      return self.forward_attention(v, scores, mask)
  
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 4 for calling the MultiHeadedAttention obj's underlying member method code with example usage: obj.forward(query, key, value, mask) and returns: self