class_docstr: ## Multi-head attention with rotary positional embeddings
  
  We override [multi-head attention from original transformer](../mha.html).
class_docstr_tok: ["#","#","Multi-head","attention","with","rotary","positional","embeddings","We","override","[","multi-head","attention","from","original","transformer","]","(","..","\/mha.html",")","."]
code: def __init__(
      self,
      heads: int,
      d_model: int,
      rope_percentage: float = 0.5,
      dropout_prob: float = 0.0,
  ):
      super().__init__(heads, d_model, dropout_prob)
  
      # Rotary positional embedding layers
      d_rope = int(self.d_k * rope_percentage)
      self.query_rotary_pe = RotaryPositionalEmbeddings(d_rope)
      self.key_rotary_pe = RotaryPositionalEmbeddings(d_rope)
  
file_path: annotated_deep_learning_paper_implementations/labml_nn/transformers/rope/__init__.py
imports: import torch
  from torch import nn
  from labml.logger import inspect
  from labml_nn.transformers.mha import MultiHeadAttention
label_desc: Use image node_id 1 to create a new RotaryPEMultiHeadAttention object from inherited base classes: MultiHeadAttention with example: obj = RotaryPEMultiHeadAttention(heads, d_model, rope_percentage, dropout_prob)