code: def test_xpos(cfg):
      PE = XPOSPositionEmbedding(head_dim=cfg["hidden_size"])
      x = torch.rand(
          cfg["max_seq_len"],
          1,
          cfg["num_attention_heads"],
          cfg["hidden_size"],
      )
  
      x_rotary = PE(x)
      assert x_rotary.shape == x.shape
  
      offset = random.choice(range(1, cfg["max_seq_len"]))
      x_rotary = PE(x[: offset + 1])
      x_rotary_offset = PE(x[offset : offset + 1], offset=offset)
      assert torch.equal(x_rotary[-1], x_rotary_offset[0])
  
file_path: NeMo/tests/collections/nlp/test_position_embedding.py
imports: import random
  import pytest
  import torch
  from nemo.collections.nlp.modules.common.megatron.layer_type import LayerType
  from nemo.collections.nlp.modules.common.megatron.position_embedding import ALiBiRelativePositionEmbedding, KERPLERelativePositionEmbedding, RotaryEmbedding, SandwichRelativePositionEmbedding, T5RelativePositionEmbedding, XPOSPositionEmbedding
  from nemo.collections.nlp.modules.common.megatron.position_embedding.rotary_position_embedding import apply_rotary_pos_emb
  from nemo.collections.nlp.modules.common.megatron.utils import init_method_normal
label_desc: Use image node_id 7 for calling a global function with example usage: test_xpos(cfg) without return types