code: def apply_rotary_pos_emb_index(q, k, cos, sin, position_id):
      # position_id: [sq, b], q, k: [sq, b, np, hn], cos: [sq, 1, hn] -> [sq, b, 1, hn]
      cos, sin = F.embedding(position_id, cos.squeeze(1)).unsqueeze(
          2
      ), F.embedding(position_id, sin.squeeze(1)).unsqueeze(2)
      q, k = (q * cos) + (rotate_half(q) * sin), (k * cos) + (
          rotate_half(k) * sin
      )
      return q, k
  
file_path: BigDL/python/llm/src/bigdl/llm/transformers/models/chatglm.py
imports: import math
  import torch
  import torch.utils.checkpoint
  import torch.nn.functional
  from typing import Optional, Tuple
  from bigdl.llm.transformers.models.utils import init_kv_cache, extend_kv_cache, append_kv_cache
label_desc: Use image node_id 2 for calling a global function with example usage: apply_rotary_pos_emb_index(q, k, cos, sin, position_id) and returns: q,  k