docstr: Args:
      x (:obj:`torch.Tensor` of shape ``(..., dim)``): Inputs.
      x_pos (:obj:`torch.Tensor` of shape ``(...)``): Positions of inputs.
docstr_tok: ["Args",":","x","(",":","obj",":","`","torch.Tensor","`","of","shape","``","(","...",",","dim",")","``",")",":","Inputs",".","x_pos","(",":","obj",":","`","torch.Tensor","`","of","shape","``","(","...",")","``",")",":","Positions","of","inputs","."]
code: def forward(self, x: torch.Tensor, x_pos: torch.Tensor):
      """
      Args:
          x (:obj:`torch.Tensor` of shape ``(..., dim)``): Inputs.
          x_pos (:obj:`torch.Tensor` of shape ``(...)``): Positions of inputs.
      """
      inv_freq = self.inv_freq.to(device=x.device, dtype=x.dtype)
  
      x_pos = x_pos * self.distance_scale
      freqs = (
          x_pos[..., None].to(self.dtype) * inv_freq[None, :]
      )  # (..., dim/2)
  
      # the same implementation as sat
      emb = torch.cat((freqs, freqs), dim=-1)  # (..., dim)
      emb_cos = emb.cos()  # (..., dim)
      emb_sin = emb.sin()  # (..., dim)
  
      rotate_x = torch.cat(
          [-x[..., x.size(-1) // 2 :], x[..., : x.size(-1) // 2]],
          dim=-1,
      )  # (..., dim)
  
      return x * emb_cos + rotate_x * emb_sin
  
imports: import math
  from typing import Union
  import torch
  import bmtrain
  import torch.nn.functional
label_desc: Use image node_id 2 for calling the RotaryEmbedding obj's underlying member method code with example usage: obj.forward(x, x_pos) and returns: unknown