code: def test_apply_rotary_pos_emb(self):
      cos, sin = self.rope_pos_emd(self.sample, self.T)
      query = self.sample.view(self.T, self.B, 1, self.C)
      expected_query = torch.tensor(
          [
              [[[1.5410, -0.2934]]],
              [[[-1.6555, -1.5263]]],
              [[[1.7231, -0.4041]]],
          ]
      )
      new_query, new_key = apply_rotary_pos_emb(query, query, cos, sin)
      self.assertTrue(
          np.allclose(
              expected_query.cpu().detach().numpy(),
              new_query.cpu().detach().numpy(),
              atol=1e-4,
          )
      )
      self.assertTrue(
          np.allclose(
              expected_query.cpu().detach().numpy(),
              new_key.cpu().detach().numpy(),
              atol=1e-4,
          )
      )
  
file_path: fairseq/tests/test_rotary_positional_embedding.py
imports: import torch
  import numpy
  import unittest
  from fairseq.modules.rotary_positional_embedding import apply_rotary_pos_emb
  from fairseq.modules import RotaryPositionalEmbedding
label_desc: Use image node_id 3 for calling the TestRotaryPositionalEmbedding obj's underlying member method code with example usage: obj.test_apply_rotary_pos_emb() without return types