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.
docstr: Compute 'Scaled Dot Product Attention' with rel. positional encoding.
  Args:
      query (torch.Tensor): (batch, time1, size)
      key (torch.Tensor): (batch, time2, size)
      value(torch.Tensor): (batch, time2, size)
      mask (torch.Tensor): (batch, time1, time2)
      pos_emb (torch.Tensor) : (batch, time1, size)
      cache (torch.Tensor) : (batch, time_cache, size)
  Returns:
      output (torch.Tensor): transformed `value` (batch, time1, d_model) weighted by the query dot key attention
      cache_next (torch.Tensor) : (batch, time_cache_next, size)
docstr_tok: ["Compute","'Scaled","Dot","Product","Attention","'","with","rel",".","positional","encoding",".","Args",":","query","(","torch.Tensor",")",":","(","batch",",","time1",",","size",")","key","(","torch.Tensor",")",":","(","batch",",","time2",",","size",")","value","(","torch.Tensor",")",":","(","batch",",","time2",",","size",")","mask","(","torch.Tensor",")",":","(","batch",",","time1",",","time2",")","pos_emb","(","torch.Tensor",")",":","(","batch",",","time1",",","size",")","cache","(","torch.Tensor",")",":","(","batch",",","time_cache",",","size",")","Returns",":","output","(","torch.Tensor",")",":","transformed","`","value","`","(","batch",",","time1",",","d_model",")","weighted","by","the","query","dot","key","attention","cache_next","(","torch.Tensor",")",":","(","batch",",","time_cache_next",",","size",")"]
code: def forward(self, query, key, value, mask, pos_emb, cache=None):
      """Compute 'Scaled Dot Product Attention' with rel. positional encoding.
      Args:
          query (torch.Tensor): (batch, time1, size)
          key (torch.Tensor): (batch, time2, size)
          value(torch.Tensor): (batch, time2, size)
          mask (torch.Tensor): (batch, time1, time2)
          pos_emb (torch.Tensor) : (batch, time1, size)
          cache (torch.Tensor) : (batch, time_cache, size)
      Returns:
          output (torch.Tensor): transformed `value` (batch, time1, d_model) weighted by the query dot key attention
          cache_next (torch.Tensor) : (batch, time_cache_next, size)
      """
      # Need to perform duplicate computations as at this point the tensors have been
      # separated by the adapter forward
      query = self.pre_norm(query)
      key = self.pre_norm(key)
      value = self.pre_norm(value)
  
      return super().forward(
          query, key, value, mask, pos_emb, cache=cache
      )
  
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 2 for calling the RelPositionMultiHeadAttentionAdapter obj's underlying member method code with example usage: obj.forward(query, key, value, mask, pos_emb, cache) and returns: super