code: def apply_rotary_pos_emb(q, k, cos, sin, position_ids, model_family):
      if model_family in [
          "llama",
          "baichuan",
          "internlm",
          "aquila",
          "gpt_neox",
          "mistral",
          "mixtral",
      ]:
          # 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]
          q_embed = (q * cos) + (rotate_half(q) * sin)
          k_embed = (k * cos) + (rotate_half(k) * sin)
          return q_embed, k_embed
      elif model_family == "gptj":
          cos = torch.repeat_interleave(cos[:, :, None, :], 2, 3)
          sin = torch.repeat_interleave(sin[:, :, None, :], 2, 3)
          q_embed = (q * cos) + (rotate_every_two(q) * sin)
          k_embed = (k * cos) + (rotate_every_two(k) * sin)
          return q_embed, k_embed
      else:
          invalidInputError(False, f"{model_family} is not supported.")
  
imports: import os
  import torch
  from bigdl.llm.utils.common import invalidInputError
  from bigdl.llm.ggml.quantize import ggml_tensor_qtype
  from bigdl.llm.transformers.utils import get_ipex_version, get_xpu_device_type
label_desc: Use image node_id 11 for calling a global function with example usage: apply_rotary_pos_emb(q, k, cos, sin, position_ids, model_family) and returns: q_embed,  k_embed, q_embed,  k_embed