+
    Pj                     \    ^ RI t ^ RIt^ RIHt RR R llt ! R R]P                  4      tR# )    N)nnc          	          V ^8  d   QhR\         P                  R\         P                  R\        \         P                  ,          R\        \        ,          /# )   qkoffset
max_period)torchTensorintfloat)formats   "p/Users/ahmed/devFolder/Ultron/claude-voice/gateway/.venv/lib/python3.14/site-packages/pocket_tts/modules/rope.py__annotate__r      sE     35 35||35||35 %,,35 e	35    c                   V P                   w  rErgVP                   w  rrWEV3WV38X  g   Q hV^ 8  g   Q hV^,          ^ 8X  g   Q hV^ 8  g   Q h\        P                  ! V^,          V P                  \        P                  R7      p\        P
                  ! V\        P                  ! V4      ) ^,          V,          ,          4      p\        P                  ! WPP                  \        P                  R7      pW,          pVP                  R^^4      pV P                  WEWg^,          ^4      p VP                  WEW^,          ^4      pV R,          P                  4       pV R,          P                  4       pVR,          P                  4       pVR,          P                  4       p\        P                  ! W,          4      p\        P                  ! W,          4      pVV,          VV,          ,
          pVV,          VV,          ,           pVV,          VV,          ,
          pVV,          VV,          ,           pV P                  p\        P                  ! VP                  V4      VP                  V4      .RR7      p\        P                  ! VP                  V4      VP                  V4      .RR7      pVP                  WEWg4      VP                  WEW4      3# )z
Args:
    q (torch.Tensor): Queries, shape `[B, T, H, D]`.
    k (torch.Tensor): Keys, shape `[B, T, H, D]`.
    offset (int): Current offset, e.g. when streaming.
    max_period (float): Maximum period for the cos and sin.
)devicedtype)dim).r   ).   )shaper
   aranger   float32expmathlogviewr   cossinr   stackto)r   r   r   r	   BTHDBkTkHkDkdsfreqstsqrqikrkirotrrotiqorqoikorkoir   qokos   &&&&                        r   
apply_roper:      s    JA!WWNBB!9$$$q5L5q5A::>>	a1fQXXU]]	CBIIbTXXj11A59:;E 
a	>BLB	Q	B	qQQ"A	qRa#A 
6	B	
6	B	
6	B	
6	B99UZ D99UZ D
t)b4i
C
t)b4i
C
t)b4i
C
t)b4i
CGGE	cffUmSVVE]3	<B	cffUmSVVE]3	<B771b 444r   c                   X   a a ] tR t^=t oRtRV3R lV 3R llltV3R lR ltRtVtV ;t	# )RotaryEmbeddingzRotary positional embedding (RoPE) from [Su et al 2022](https://arxiv.org/abs/2104.09864).

Args:
    max_period (float): Maximum period of the rotation frequencies.
c                0   < V ^8  d   QhRS[ S[,          /# )r   r	   )r   r   )r   __classdict__s   "r   r   RotaryEmbedding.__annotate__D   s     % %53; %r   c                0   < \         SV `  4        Wn        R # )N)super__init__r	   )selfr	   	__class__s   &&r   rB   RotaryEmbedding.__init__D   s    $r   c                x   < V ^8  d   QhRS[ P                  RS[ P                  RS[ P                  S[,          /# )r   r   r   r   )r
   r   r   )r   r>   s   "r   r   r?   H   s3     9 9 9%,, 9s@R 9r   c                .    \        WW0P                  4      # )z+Apply rope rotation to query or key tensor.)r:   r	   )rC   r   r   r   s   &&&&r   forwardRotaryEmbedding.forwardH   s    !88r   )r	   )g     @)
__name__
__module____qualname____firstlineno____doc__rB   rH   __static_attributes____classdictcell____classcell__)rD   r>   s   @@r   r<   r<   =   s#     % %9 9 9r   r<   )r   i'  )r   r
   r   r:   Moduler<    r   r   <module>rT      s$      35l9bii 9r   