class_docstr: Multi-Head Attention layer of Transformer-XL with support of relative positional encoding.
  Paper: https://arxiv.org/abs/1901.02860
  Args:
      n_head (int): number of heads
      n_feat (int): size of the features
      dropout_rate (float): dropout rate
      proj_dim (int, optional): Optional integer value for projection before computing attention.
          If None, then there is no projection (equivalent to proj_dim = n_feat).
          If > 0, then will project the n_feat to proj_dim before calculating attention.
          If <0, then will equal n_head, so that each head has a projected dimension of 1.
      adapter_strategy: By default, MHAResidualAddAdapterStrategyConfig. An adapter composition function object.
code: def __init__(
      self,
      n_head: int,
      n_feat: int,
      dropout_rate: float,
      proj_dim: Optional[int] = None,
      adapter_strategy: MHAResidualAddAdapterStrategyConfig = None,
  ):
      super().__init__(
          n_head=n_head,
          n_feat=n_feat,
          dropout_rate=dropout_rate,
          pos_bias_u=None,
          pos_bias_v=None,
          max_cache_len=0,
      )
  
      self.pre_norm = nn.LayerNorm(n_feat)
  
      # Set the projection dim to number of heads automatically
      if proj_dim is not None and proj_dim < 1:
          proj_dim = n_head
  
      self.proj_dim = proj_dim
  
      # Recompute weights for projection dim
      if self.proj_dim is not None:
          if self.proj_dim % n_head != 0:
              raise ValueError(
                  f"proj_dim ({proj_dim}) is not divisible by n_head ({n_head})"
              )
  
          self.d_k = self.proj_dim // n_head
          self.s_d_k = math.sqrt(self.d_k)
          self.linear_q = nn.Linear(n_feat, self.proj_dim)
          self.linear_k = nn.Linear(n_feat, self.proj_dim)
          self.linear_v = nn.Linear(n_feat, self.proj_dim)
          self.linear_out = nn.Linear(self.proj_dim, n_feat)
          self.linear_pos = nn.Linear(n_feat, self.proj_dim, bias=False)
          self.pos_bias_u = nn.Parameter(
              torch.FloatTensor(self.h, self.d_k)
          )
          self.pos_bias_v = nn.Parameter(
              torch.FloatTensor(self.h, self.d_k)
          )
  
      # Setup adapter strategy
      self.setup_adapter_strategy(adapter_strategy)
  
      # reset parameters for Q to be identity operation
      self.reset_parameters()
  
imports: import math
  from dataclasses import dataclass, field
  from typing import Any, Optional
  import torch
  from torch import nn
  from nemo.collections.asr.parts.submodules import multi_head_attention
  from nemo.collections.common.parts import adapter_modules
  from nemo.core.classes.mixins import adapter_mixin_strategies
label_desc: Use image node_id 1 to create a new RelPositionMultiHeadAttentionAdapter object from inherited base classes: mha, adapter_modules with example: obj = RelPositionMultiHeadAttentionAdapter(n_head, n_feat, dropout_rate, proj_dim, adapter_strategy)