class_docstr: Multi-headed self-attention for WavLM model :cite:`chen2022wavlm`.
  Wraps around ``torch.nn.MultiheadAttention``, creating relaive position embeddings and passing them to multi-headed
  attention as a mask.
  Source: https://github.com/microsoft/unilm/blob/2d8302f09c99bca2b82e6e868d81d4281cceebc8/wavlm/modules.py#L303-L763
  
  Args:
      embed_dim (int): Total dimension of the model.
      num_heads (int): The number of heads.
      dropout (float, optional): Dropout probability on attn_output_weights. (Default: to ``0.0``)
      bias (bool, optional): If ``True``, add bias to input / output projection layers. (Default: ``True``)
      has_relative_attention_bias (bool, optional): If ``True``, apply relative position embedding.
          Necessary in the first encoder layer, but not in the subsequent ones. (Default: ``False``)
      num_buckets (int, optional): Number of buckets for relative position embedding. (Default: ``32``)
      max_distance (int, optional): Naximum distance for relative position embedding. (Default: ``128``)
      gru_rel_pos (bool, optional): If ``True``, apply gated relative position embedding. (Default: ``False``)
docstr: Compute relative position embeddings for WavLM model.
  Args:
      query_length (int): Query position can take values between 0 and ``query_length - 1``.
      key_length (int): Key position can take values between 0 and ``key_length - 1``.
  Returns:
      Tensor of shape `(num_heads, query_length, key_length)`, relative positions embeddings
code: def compute_bias(self, query_length: int, key_length: int) -> Tensor:
      """Compute relative position embeddings for WavLM model.
      Args:
          query_length (int): Query position can take values between 0 and ``query_length - 1``.
          key_length (int): Key position can take values between 0 and ``key_length - 1``.
      Returns:
          Tensor of shape `(num_heads, query_length, key_length)`, relative positions embeddings
      """
      context_position = torch.arange(query_length, dtype=torch.long)[
          :, None
      ]
      memory_position = torch.arange(key_length, dtype=torch.long)[
          None, :
      ]
      relative_position = (
          memory_position - context_position
      )  # Shape (query_length, key_length)
      relative_position_bucket = self._relative_positions_bucket(
          relative_position, bidirectional=True
      )
      relative_position_bucket = relative_position_bucket.to(
          self.rel_attn_embed.weight.device
      )
      values = self.rel_attn_embed(
          relative_position_bucket
      )  # Shape (query_length, key_length, num_heads)
      values = values.permute([2, 0, 1])
      return values
  
file_path: audio/src/torchaudio/models/wav2vec2/wavlm_attention.py
imports: import math
  from typing import Optional, Tuple
  import torch
  from torch import nn, Tensor
label_desc: Use image node_id 2 for calling the WavLMSelfAttention obj's underlying member method code with example usage: obj.compute_bias(query_length, key_length) and returns: values