class_docstr: kerple (Attention with Linear Biases) relative position embedding for auto-regressive decoder
  and joint encoder (symmetric for forward and backward distance).
  Based on https://arxiv.org/bas/2108.12409
class_docstr_tok: ["kerple","(","Attention","with","Linear","Biases",")","relative","position","embedding","for","auto-regressive","decoder","and","joint","encoder","(","symmetric","for","forward","and","backward","distance",")",".","Based","on","https",":","\/\/arxiv.org\/bas\/2108.12409"]
code: def forward(self, query_seq_length, key_seq_length):
      # used cached relative position if possible
      max_seq_len = max(query_seq_length, key_seq_length)
      if max_seq_len > self.max_seq_len:
          relative_position = build_relative_position(
              max_seq_len, max_seq_len, self.num_attention_heads
          )
      else:
          relative_position = self.relative_position
      # shape (num_attention_heads, query_seq_length, key_seq_length)
      relative_position = relative_position[
          :, :query_seq_length, :key_seq_length
      ]
      # if not bidirectional, mask out the future positions
      if not self.bidirectional:
          relative_position = torch.tril(relative_position)
  
      # shape (1, num_heads, query_length, key_length)
      return -self.kerple_b * torch.log(
          1
          + self.kerple_a
          * relative_position.unsqueeze(0).pow(self.kerple_p)
      )
  
imports: import math
  import torch
  from nemo.collections.nlp.modules.common.megatron.alibi_relative_position_embedding import build_relative_position, build_slopes
label_desc: Use image node_id 2 for calling the KERPLERelativePositionEmbedding obj's underlying member method code with example usage: obj.forward(query_seq_length, key_seq_length) and returns: unknown