code: def apply_rotary_pos_emb_single(x, cos, sin, position_ids):
      # The first two dimensions of cos and sin are always 1, so we can `squeeze` them.
      cos = cos.squeeze(1).squeeze(0)  # [seq_len, dim]
      sin = sin.squeeze(1).squeeze(0)  # [seq_len, dim]
      cos = cos[position_ids].unsqueeze(1)  # [bs, 1, seq_len, dim]
      sin = sin[position_ids].unsqueeze(1)  # [bs, 1, seq_len, dim]
      x_embed = (x * cos) + (rotate_half(x) * sin)
      return x_embed
  
file_path: BigDL/python/llm/example/CPU/Applications/streaming-llm/streaming_llm/modify_llama.py
imports: import math
  from typing import Optional, Tuple
  import torch
  from torch import nn
  import torch.utils.checkpoint
  import torch.nn.functional
  from transformers.models.llama.modeling_llama import LlamaAttention, rotate_half, apply_rotary_pos_emb, repeat_kv
  import types
label_desc: Use image node_id 1 for calling a global function with example usage: apply_rotary_pos_emb_single(x, cos, sin, position_ids) and returns: x_embed