code: def apply_rotary_pos_emb(q, k, 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]
      q_embed = (q * cos) + (rotate_half(q) * sin)
      k_embed = (k * cos) + (rotate_half(k) * sin)
      return q_embed, k_embed
  
imports: from .configuration_baichuan import BaiChuanConfig
  from transformers import PreTrainedModel, add_start_docstrings
  from transformers.activations import ACT2FN
  from transformers.modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast, SequenceClassifierOutputWithPast
  from transformers.utils import logging, add_start_docstrings_to_model_forward, replace_return_docstrings
  import math
  from typing import List, Optional, Tuple, Union
  import torch
  import torch.utils.checkpoint
  from torch import nn
  from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
label_desc: Use image node_id 4 for calling a global function with example usage: apply_rotary_pos_emb(q, k, cos, sin, position_ids) and returns: q_embed,  k_embed