class_docstr: Facebook implementation of rotary embeddings.
class_docstr_tok: ["Facebook","implementation","of","rotary","embeddings","."]
code: def apply_rotary_emb(
      self, xq: torch.Tensor, xk: torch.Tensor, freqs_cis: torch.Tensor
  ) -> Tuple[torch.Tensor, torch.Tensor]:
      xq_ = torch.view_as_complex(
          xq.float().reshape(*xq.shape[:-1], -1, 2)
      )
      xk_ = torch.view_as_complex(
          xk.float().reshape(*xk.shape[:-1], -1, 2)
      )
      freqs_cis = self.reshape_for_broadcast(freqs_cis, xq_)
  
      xq_out = torch.view_as_real(xq_ * freqs_cis).flatten(3)
      xk_out = torch.view_as_real(xk_ * freqs_cis).flatten(3)
      return xq_out.type_as(xq), xk_out.type_as(xk)
  
imports: import torch
  import math
  from typing import Tuple
  from einops import repeat
label_desc: Use image node_id 3 for calling the RotaryLLAMA obj's underlying member method code with example usage: obj.apply_rotary_emb(xq, xk, freqs_cis) and returns: xq_out,  xk_out