class_docstr: Multi-Head Attention layer inheriting SequenceModule.
  
  Comparing default MHA module in ESPnet, this module returns additional dummy state
  and has step function for autoregressive inference.
  
  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).
code: def forward(self, query, memory=None, mask=None, *args, **kwargs):
      """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).
  
      """
      # self-attention
      if memory is None:
          memory = query
      q, k, v = self.forward_qkv(query=query, key=memory, value=memory)
      scores = torch.matmul(q, k.transpose(-2, -1)) / math.sqrt(
          self.d_k
      )
      return self.forward_attention(v, scores, mask), None
  
file_path: espnet/espnet2/asr/state_spaces/attention.py
imports: import math
  import numpy
  import torch
  from torch import nn
  from espnet2.asr.state_spaces.base import SequenceModule
label_desc: Use image node_id 4 for calling the MultiHeadedAttention obj's underlying member method code with example usage: obj.forward(query, memory, mask) and returns: self,  None