class_docstr: RelPositionMultiHeadedAttention definition.
  
  Args:
      num_heads: Number of attention heads.
      embed_size: Embedding size.
      dropout_rate: Dropout rate.
docstr: Compute attention context vector.
  
  Args:
      value: Transformed value. (B, H, T_2, d_k)
      scores: Attention score. (B, H, T_1, T_2)
      mask: Source mask. (B, T_2)
      chunk_mask: Chunk mask. (T_1, T_1)
  
  Returns:
     attn_output: Transformed value weighted by attention score. (B, T_1, H * d_k)
code: def forward_attention(
      self,
      value: torch.Tensor,
      scores: torch.Tensor,
      mask: torch.Tensor,
      chunk_mask: Optional[torch.Tensor] = None,
  ) -> torch.Tensor:
      """Compute attention context vector.
  
      Args:
          value: Transformed value. (B, H, T_2, d_k)
          scores: Attention score. (B, H, T_1, T_2)
          mask: Source mask. (B, T_2)
          chunk_mask: Chunk mask. (T_1, T_1)
  
      Returns:
         attn_output: Transformed value weighted by attention score. (B, T_1, H * d_k)
  
      """
      batch_size = scores.size(0)
      mask = mask.unsqueeze(1).unsqueeze(2)
  
      if chunk_mask is not None:
          mask = chunk_mask.unsqueeze(0).unsqueeze(1) | mask
  
      scores = scores.masked_fill(mask, float("-inf"))
      self.attn = torch.softmax(scores, dim=-1).masked_fill(mask, 0.0)
  
      attn_output = self.dropout(self.attn)
      attn_output = torch.matmul(attn_output, value)
  
      attn_output = self.linear_out(
          attn_output.transpose(1, 2)
          .contiguous()
          .view(batch_size, -1, self.num_heads * self.d_k)
      )
  
      return attn_output
  
file_path: espnet/espnet2/asr_transducer/encoder/modules/attention.py
imports: import math
  from typing import Optional, Tuple
  import torch
label_desc: Use image node_id 6 for calling the RelPositionMultiHeadedAttention obj's underlying member method code with example usage: obj.forward_attention(value, scores, mask, chunk_mask) and returns: attn_output