code: def _rope_embedding(
      Q,
      Q_row_stride,
      cos,
      cos_row_stride,
      sin,
      sin_row_stride,
      seqlen,
      head_dim,
      BACKWARD_PASS: tl.constexpr,
      BLOCK_SIZE: tl.constexpr,
  ):
      """
      Calculates the RoPE Embedding quickly
      RoPE is Q * cos + rotate_half(Q) * sin
      See our blog post for more info
      """
      row_position = tl.program_id(0)
      head_position = tl.program_id(1)
      col_offsets = tl.arange(0, BLOCK_SIZE)
      half_head_dim = head_dim // 2
      mask = col_offsets < half_head_dim
  
      Q1 = tl.load(
          Q
          + row_position * Q_row_stride
          + head_position * head_dim
          + half_head_dim * 0
          + col_offsets,
          mask=mask,
          other=0,
      )
      Q2 = tl.load(
          Q
          + row_position * Q_row_stride
          + head_position * head_dim
          + half_head_dim * 1
          + col_offsets,
          mask=mask,
          other=0,
      )
      sin1 = tl.load(
          sin
          + (row_position % seqlen) * sin_row_stride
          + half_head_dim * 0
          + col_offsets,
          mask=mask,
          other=0,
      )
      cos1 = tl.load(
          cos
          + (row_position % seqlen) * cos_row_stride
          + half_head_dim * 0
          + col_offsets,
          mask=mask,
          other=0,
      )
  
      if BACKWARD_PASS:
          # See our blog post for more info.
          sin1 = -sin1
      pass
  
      tl.store(
          Q
          + row_position * Q_row_stride
          + head_position * head_dim
          + half_head_dim * 0
          + col_offsets,
          Q1 * cos1 - Q2 * sin1,
          mask=mask,
      )
      tl.store(
          Q
          + row_position * Q_row_stride
          + head_position * head_dim
          + half_head_dim * 1
          + col_offsets,
          Q2 * cos1 + Q1 * sin1,
          mask=mask,
      )
  
file_path: unsloth/unsloth/kernels/rope_embedding.py
imports: import triton
  import triton.language
  import torch
  from .utils import calculate_settings
label_desc: Use image node_id 1 for calling a global function with example usage: _rope_embedding(Q, Q_row_stride, cos, cos_row_stride, sin, sin_row_stride, seqlen, head_dim, BACKWARD_PASS, BLOCK_SIZE) without return types