class_docstr: RotaryRelativePositionBias module definition.
  
  Args:
      size: Module embedding size.
      max_positions: Maximum number of relative positions.
class_docstr_tok: ["RotaryRelativePositionBias","module","definition",".","Args",":","size",":","Module","embedding","size",".","max_positions",":","Maximum","number","of","relative","positions","."]
docstr: Compute sinusoidal positional embeddings.
  
  Args:
      max_positions: Maximum number of positions.
      size: Input size.
  
  Returns:
      : Sine elements. (max_positions, size // 2)
      : Cos elements. (max_positions, size // 2)
docstr_tok: ["Compute","sinusoidal","positional","embeddings",".","Args",":","max_positions",":","Maximum","number","of","positions",".","size",":","Input","size",".","Returns",":",":","Sine","elements",".","(","max_positions",",","size","\/\/","2",")",":","Cos","elements",".","(","max_positions",",","size","\/\/","2",")"]
code: def get_sinusoid_embeddings(
      max_positions: int,
      size: int,
  ) -> Tuple[torch.Tensor, torch.Tensor]:
      """Compute sinusoidal positional embeddings.
  
      Args:
          max_positions: Maximum number of positions.
          size: Input size.
  
      Returns:
          : Sine elements. (max_positions, size // 2)
          : Cos elements. (max_positions, size // 2)
  
      """
      half_size = size // 2
  
      emb = math.log(10000) / half_size
      emb = torch.exp(torch.arange(half_size, dtype=torch.float) * -emb)
      emb = torch.arange(max_positions, dtype=torch.float).unsqueeze(
          1
      ) * emb.unsqueeze(0)
  
      return torch.sin(emb), torch.cos(emb)
  
file_path: espnet/espnet2/asr_transducer/decoder/modules/mega/positional_bias.py
imports: import math
  from typing import Tuple
  import torch
label_desc: Use image node_id 3 for calling the RotaryRelativePositionBias obj's underlying member method code with example usage: obj.get_sinusoid_embeddings(max_positions, size) and returns: torch,  torch