class_docstr: Multi-Head Attention layer with relative position encoding (old version).
  
  Details can be found in https://github.com/espnet/espnet/pull/2816.
  
  Paper: https://arxiv.org/abs/1901.02860
  
  Args:
      n_head (int): The number of heads.
      n_feat (int): The number of features.
      dropout_rate (float): Dropout rate.
      zero_triu (bool): Whether to zero the upper triangular part of attention matrix.
class_docstr_tok: ["Multi-Head","Attention","layer","with","relative","position","encoding","(","old","version",")",".","Details","can","be","found","in","https",":","\/\/github.com\/espnet\/espnet\/pull\/2816",".","Paper",":","https",":","\/\/arxiv.org\/abs\/1901.02860","Args",":","n_head","(","int",")",":","The","number","of","heads",".","n_feat","(","int",")",":","The","number","of","features",".","dropout_rate","(","float",")",":","Dropout","rate",".","zero_triu","(","bool",")",":","Whether","to","zero","the","upper","triangular","part","of","attention","matrix","."]
docstr: Construct an RelPositionMultiHeadedAttention object.
docstr_tok: ["Construct","an","RelPositionMultiHeadedAttention","object","."]
code: def __init__(self, n_head, n_feat, dropout_rate, zero_triu=False):
      """Construct an RelPositionMultiHeadedAttention object."""
      super().__init__(n_head, n_feat, dropout_rate)
      self.zero_triu = zero_triu
      # linear transformation for positional encoding
      self.linear_pos = nn.Linear(n_feat, n_feat, bias=False)
      # these two learnable bias are used in matrix c and matrix d
      # as described in https://arxiv.org/abs/1901.02860 Section 3.3
      self.pos_bias_u = nn.Parameter(torch.Tensor(self.h, self.d_k))
      self.pos_bias_v = nn.Parameter(torch.Tensor(self.h, self.d_k))
      torch.nn.init.xavier_uniform_(self.pos_bias_u)
      torch.nn.init.xavier_uniform_(self.pos_bias_v)
  
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 1 to create a new LegacyRelPositionMultiHeadedAttention object from inherited base classes: MultiHeadedAttention with example: obj = LegacyRelPositionMultiHeadedAttention(n_head, n_feat, dropout_rate, zero_triu)