code: def torch_rotary_emb(x, cos, sin):
      seq_len, h, dim = x.shape
      x0 = x[:, :, 0 : dim // 2]
      x1 = x[:, :, dim // 2 : dim]
      cos = cos.view((seq_len, 1, dim // 2))
      sin = sin.view((seq_len, 1, dim // 2))
      o0 = x0 * cos - x1 * sin
      o1 = x0 * sin + x1 * cos
      return torch.cat((o0, o1), dim=-1)
  
imports: import pytest
  import torch
  from packaging import version
label_desc: Use image node_id 1 for calling a global function with example usage: torch_rotary_emb(x, cos, sin) and returns: torch