class_docstr: RelPositionMultiHeadedAttention definition.
  
  Args:
      num_heads: Number of attention heads.
      embed_size: Embedding size.
      dropout_rate: Dropout rate.
docstr: Compute scaled dot product attention with rel. positional encoding.
  
  Args:
      query: Query tensor. (B, T_1, size)
      key: Key tensor. (B, T_2, size)
      value: Value tensor. (B, T_2, size)
      pos_enc: Positional embedding tensor. (B, 2 * T_1 - 1, size)
      mask: Source mask. (B, T_2)
      chunk_mask: Chunk mask. (T_1, T_1)
      left_context: Number of previous frames to use for current chunk
                    attention computation.
  
  Returns:
      : Output tensor. (B, T_1, H * d_k)
code: def forward(
      self,
      query: torch.Tensor,
      key: torch.Tensor,
      value: torch.Tensor,
      pos_enc: torch.Tensor,
      mask: torch.Tensor,
      chunk_mask: Optional[torch.Tensor] = None,
      left_context: int = 0,
  ) -> torch.Tensor:
      """Compute scaled dot product attention with rel. positional encoding.
  
      Args:
          query: Query tensor. (B, T_1, size)
          key: Key tensor. (B, T_2, size)
          value: Value tensor. (B, T_2, size)
          pos_enc: Positional embedding tensor. (B, 2 * T_1 - 1, size)
          mask: Source mask. (B, T_2)
          chunk_mask: Chunk mask. (T_1, T_1)
          left_context: Number of previous frames to use for current chunk
                        attention computation.
  
      Returns:
          : Output tensor. (B, T_1, H * d_k)
  
      """
      q, k, v = self.forward_qkv(query, key, value)
  
      scores = self.compute_att_score(
          q, k, pos_enc, left_context=left_context
      )
  
      return self.forward_attention(
          v, scores, mask, chunk_mask=chunk_mask
      )
  
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 7 for calling the RelPositionMultiHeadedAttention obj's underlying member method code with example usage: obj.forward(query, key, value, pos_enc, mask, chunk_mask, left_context) and returns: self