code: def forward(self, x, offset=0, downscale=False):
      length, b = x.shape[0], x.shape[1]
      x = rearrange(x, "s b np hn -> (b np) s hn")
      min_pos = -(length + offset) // 2
      max_pos = length + offset + min_pos
      scale = (
          self.scale
          ** torch.arange(min_pos, max_pos, 1)
          .to(self.scale)
          .div(self.scale_base)[:, None]
      )
      sin, cos = fixed_pos_embedding(scale)
  
      if scale.shape[0] > length:
          scale = scale[-length:]
          sin = sin[-length:]
          cos = cos[-length:]
  
      if downscale:
          scale = 1 / scale
  
      x = apply_rotary_pos_emb(x, sin, cos, scale)
      x = rearrange(x, "(b np) s hn -> s b np hn", b=b)
      return x
  
file_path: NeMo/nemo/collections/nlp/modules/common/megatron/position_embedding/xpos_position_embedding.py
imports: import torch
  import torch.nn
  from einops import rearrange
  from nemo.utils.decorators import experimental
label_desc: Use image node_id 2 for calling the XPOSPositionEmbedding obj's underlying member method code with example usage: obj.forward(x, offset, downscale) and returns: x