class_docstr: RelPositionMultiHeadedAttention definition.
  
  Args:
      num_heads: Number of attention heads.
      embed_size: Embedding size.
      dropout_rate: Dropout rate.
docstr: Construct an MultiHeadedAttention object.
code: def __init__(
      self,
      num_heads: int,
      embed_size: int,
      dropout_rate: float = 0.0,
      simplified_attention_score: bool = False,
  ) -> None:
      """Construct an MultiHeadedAttention object."""
      super().__init__()
  
      self.d_k = embed_size // num_heads
      self.num_heads = num_heads
  
      assert self.d_k * num_heads == embed_size, (
          "embed_size (%d) must be divisible by num_heads (%d)",
          (embed_size, num_heads),
      )
  
      self.linear_q = torch.nn.Linear(embed_size, embed_size)
      self.linear_k = torch.nn.Linear(embed_size, embed_size)
      self.linear_v = torch.nn.Linear(embed_size, embed_size)
  
      self.linear_out = torch.nn.Linear(embed_size, embed_size)
  
      if simplified_attention_score:
          self.linear_pos = torch.nn.Linear(embed_size, num_heads)
  
          self.compute_att_score = (
              self.compute_simplified_attention_score
          )
      else:
          self.linear_pos = torch.nn.Linear(
              embed_size, embed_size, bias=False
          )
  
          self.pos_bias_u = torch.nn.Parameter(
              torch.Tensor(num_heads, self.d_k)
          )
          self.pos_bias_v = torch.nn.Parameter(
              torch.Tensor(num_heads, self.d_k)
          )
          torch.nn.init.xavier_uniform_(self.pos_bias_u)
          torch.nn.init.xavier_uniform_(self.pos_bias_v)
  
          self.compute_att_score = self.compute_attention_score
  
      self.dropout = torch.nn.Dropout(p=dropout_rate)
      self.attn = None
  
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 1 to create a new RelPositionMultiHeadedAttention object from inherited base classes: torch.nn with example: obj = RelPositionMultiHeadedAttention(num_heads, embed_size, dropout_rate, simplified_attention_score)