+
    NV-jT"  ã                   ó„   € ^ RI t ^ RIHtHt ^ RIHt ^ RIHt ^ RI	H
t
  ! R R]
4      t ! R R]
4      t ! R	 R
]
4      tR# )é    N)ÚCallableÚOptional)Útanh)ÚModulec                   óV   a a€ ] tR t^t oRtRV3R lV 3R llltR tRR ltRtVt	V ;t
# )	ÚRNNaW  An Elman recurrent layer.

The input is a sequence of shape ``NLD`` or ``LD`` where:

* ``N`` is the optional batch dimension
* ``L`` is the sequence length
* ``D`` is the input's feature dimension

Concretely, for each element along the sequence length axis, this
layer applies the function:

.. math::

    h_{t + 1} = \text{tanh} (W_{ih}x_t + W_{hh}h_t + b)

The hidden state :math:`h` has shape ``NH`` or ``H``, depending on
whether the input is batched or not. Returns the hidden state at each
time step, of shape ``NLH`` or ``LH``.

Args:
    input_size (int): Dimension of the input, ``D``.
    hidden_size (int): Dimension of the hidden state, ``H``.
    bias (bool, optional): Whether to use a bias. Default: ``True``.
    nonlinearity (callable, optional): Non-linearity to use. If ``None``,
        then func:`tanh` is used. Default: ``None``.
c          	      óB   <€ V ^8„  d   QhRS[ RS[ RS[RS[S[,          /# )é   Ú
input_sizeÚhidden_sizeÚbiasÚnonlinearity)ÚintÚboolr   r   )ÚformatÚ__classdict__s   "€Úh/Volumes/fast/ai/experiments/ui-tars-smoke/.venv/lib/python3.14/site-packages/mlx/nn/layers/recurrent.pyÚ__annotate__ÚRNN.__annotate__'   s8   ø€ ÷ 
ñ 
áð
ñ ð
ñ ð	
ñ
 ™xÕ(ñ
ó    c                óþ  <€ \         SV `  4        T;'       g    \        V n        \	        V P                  4      '       g   \        R V R24      hR\        P                  ! V4      ,          pW n        \        P                  P                  V) WRV3R7      V n        \        P                  P                  V) WRV3R7      V n        V'       d+   \        P                  P                  V) WR3R7      V n        R# RV n        R# )z.Nonlinearity must be callable. Current value: Ú.ç      ð?©ÚlowÚhighÚshapeN)ÚsuperÚ__init__r   r   ÚcallableÚ
ValueErrorÚmathÚsqrtr   ÚmxÚrandomÚuniformÚWxhÚWhhr   )Úselfr   r   r   r   ÚscaleÚ	__class__s   &&&&& €r   r   ÚRNN.__init__'   sê   ø€ ô 	‰ÑÔà(×0Ð0¬DˆÔÜ˜×)Ñ)×*Ò*ÜØ@ÀÀÈaÐPóð ð ”d—i’i Ó,Õ,ˆØ&ÔÜ—9‘9×$Ñ$Ø�˜U¸
Ð*Cð %ó 
ˆŒô —9‘9×$Ñ$Ø�˜U¸Ð*Dð %ó 
ˆŒ÷
 ô �I‰I×Ñ 5 &¨u¸NÐÓKð 	Ž	ð ð 	Ž	r   c           	     ó”   € R V P                   P                  ^,           RV P                   RV P                   RV P                  RJ 2# )úinput_dims=ú, hidden_size=z, nonlinearity=ú, bias=N)r'   r   r   r   r   ©r)   s   &r   Ú_extra_reprÚRNN._extra_reprD   sT   € à˜$Ÿ(™(Ÿ.™.¨Õ+Ð,ð -Ø×+Ñ+Ð,ð -Ø ×-Ñ-Ð.¨g°d·i±iÀtÐ6KÐ5LðNð	
r   c                ó  € V P                   e7   \        P                  ! V P                   WP                  P                  4      pMWP                  P                  ,          p. p\        VP                  R,          4       Fk  pVe7   \        P                  ! VRVR3,          W P                  P                  4      pMVRVR3,          pV P                  V4      pVP                  V4       Km  	  \        P                  ! VRR7      # )N.ºNNN©Úaxiséþÿÿÿ)r   r$   Úaddmmr'   ÚTÚranger   r(   r   ÚappendÚstack)r)   ÚxÚhiddenÚ
all_hiddenÚidxs   &&&  r   Ú__call__ÚRNN.__call__K   s»   € Ø�9‰9Ò Ü—’˜Ÿ™ A§x¡x§z¡zÓ2‰Aà—H‘H—J‘J•ˆAàˆ
Ü˜Ÿ™ �Ö%ˆCØÒ!ÜŸš ! C¨¨a K¥.°&¿(¹(¿*¹*ÓE‘à˜3  Q˜;��Ø×&Ñ& vÓ.ˆFØ×Ñ˜fÖ%ñ &ô �xŠx˜
¨Ô,Ð,r   )r(   r'   r   r   r   )TN©N©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r2   rB   Ú__static_attributes__Ú__classdictcell__Ú__classcell__©r+   r   s   @@r   r   r      s#   ù‡ € ñ÷6
õ 
ò:
÷-ô -r   r   c                   óV   a a€ ] tR t^]t oRtRV3R lV 3R llltR tRR ltRtVt	V ;t
# )	ÚGRUa”  A gated recurrent unit (GRU) RNN layer.

The input has shape ``NLD`` or ``LD`` where:

* ``N`` is the optional batch dimension
* ``L`` is the sequence length
* ``D`` is the input's feature dimension

Concretely, for each element of the sequence, this layer computes:

.. math::

    \begin{aligned}
    r_t &= \sigma (W_{xr}x_t + W_{hr}h_t + b_{r}) \\
    z_t &= \sigma (W_{xz}x_t + W_{hz}h_t + b_{z}) \\
    n_t &= \text{tanh}(W_{xn}x_t + b_{n} + r_t \odot (W_{hn}h_t + b_{hn})) \\
    h_{t + 1} &= (1 - z_t) \odot n_t + z_t \odot h_t
    \end{aligned}

The hidden state :math:`h` has shape ``NH`` or ``H`` depending on
whether the input is batched or not. Returns the hidden state at each
time step of shape ``NLH`` or ``LH``.

Args:
    input_size (int): Dimension of the input, ``D``.
    hidden_size (int): Dimension of the hidden state, ``H``.
    bias (bool): Whether to use biases or not. Default: ``True``.
c                ó,   <€ V ^8„  d   QhRS[ RS[ RS[/# ©r
   r   r   r   ©r   r   )r   r   s   "€r   r   ÚGRU.__annotate__{   s)   ø€ ÷ 
ñ 
áð
ñ ð
ñ ñ	
r   c                ó  <€ \         SV `  4        W n        R \        P                  ! V4      ,          p\
        P                  P                  V) V^V,          V3R7      V n        \
        P                  P                  V) V^V,          V3R7      V n	        V'       d,   \
        P                  P                  V) V^V,          3R7      MRV n
        V'       d+   \
        P                  P                  V) WB3R7      V n        R# RV n        R# ©r   r   N)r   r   r   r"   r#   r$   r%   r&   ÚWxÚWhÚbÚbhn©r)   r   r   r   r*   r+   s   &&&& €r   r   ÚGRU.__init__{   sí   ø€ ô 	‰ÑÔà&ÔØ”d—i’i Ó,Õ,ˆÜ—)‘)×#Ñ#Ø�˜U¨1¨{­?¸JÐ*Gð $ó 
ˆŒô —)‘)×#Ñ#Ø�˜U¨1¨{­?¸KÐ*Hð $ó 
ˆŒ÷
 ô �I‰I×Ñ 5 &¨u¸QÀ½_Ð<NÐÔOàð 	Œ÷ ô �I‰I×Ñ 5 &¨u¸NÐÓKð 	Žð ð 	Žr   c                óz   € R V P                   P                  ^,           RV P                   RV P                  RJ 2# ©r.   r/   r0   N)rW   r   r   rY   r1   s   &r   r2   ÚGRU._extra_repr–   sC   € à˜$Ÿ'™'Ÿ-™-¨Õ*Ð+ð ,Ø×+Ñ+Ð,¨G°D·F±FÀ$Ð4FÐ3GðIð	
r   c                óJ  € V P                   e7   \        P                  ! V P                   WP                  P                  4      pMWP                  P                  ,          pVRR V P
                  ) 13,          pVRV P
                  ) R 13,          p. p\        VP                  R,          4       EFY  pVRVR3,          pVeu   W P                  P                  ,          pVRR V P
                  ) 13,          p	VRV P
                  ) R 13,          p
V P                  e   W P                  ,          p
Wy,           p\        P                  ! V4      p\        P                  ! V^RR7      w  r¼VRVR3,          pVe   WÛX
,          ,           pM'V P                  e   WÛV P                  ,          ,           p\        P                  ! V4      pVe   ^V,
          V,          WÂ,          ,           pM^V,
          V,          pVP                  V4       EK\  	  \        P                  ! VRR7      # ©N.r5   r6   r8   éÿÿÿÿ)rY   r$   r9   rW   r:   r   r;   r   rX   rZ   ÚsigmoidÚsplitr   r<   r=   )r)   r>   r?   Úx_rzÚx_nr@   rA   ÚrzÚh_projÚ	h_proj_rzÚh_proj_nÚrÚzÚns   &&&           r   rB   ÚGRU.__call__œ   sº  € Ø�6‰6ÒÜ—’˜Ÿ™ §G¡G§I¡IÓ.‰Aà—G‘G—I‘I•ˆAà�Ð)˜×)Ñ)Ð)Ð)Ð)Õ*ˆØ��d×&Ñ&Ð&Ñ(Ð(Õ)ˆàˆ
ä˜Ÿ™ �×%ˆCØ�c˜3 �kÕ"ˆBØÒ!Ø§'¡'§)¡)Õ+�Ø" 3Ð(;¨4×+;Ñ+;Ð*;Ð(;Ð#;Õ<�	Ø! #¨×(8Ñ(8Ð'8Ñ':Ð":Õ;�à—8‘8Ò'Ø§¡Õ(�Hà•^�ä—’˜B“ˆBä—8’8˜B ¨Ô+‰DˆAà�C˜˜a�KÕ ˆAàÒ!Ø˜H�Õ$‘Ø—‘Ò%Ø˜DŸH™H�Õ$�Ü—’˜“
ˆAàÒ!Ø˜a�% 1� q¥zÕ1‘à˜a�% 1��à×Ñ˜f×%ñ; &ô> �xŠx˜
¨Ô,Ð,r   )rX   rW   rY   rZ   r   ©TrD   rE   rN   s   @@r   rP   rP   ]   s#   ù‡ € ñ÷:
õ 
ò6
÷*-ô *-r   rP   c                   óV   a a€ ] tR t^Ét oRtRV3R lV 3R llltR tRR ltRtVt	V ;t
# )	ÚLSTMa  An LSTM recurrent layer.

The input has shape ``NLD`` or ``LD`` where:

* ``N`` is the optional batch dimension
* ``L`` is the sequence length
* ``D`` is the input's feature dimension

Concretely, for each element of the sequence, this layer computes:

.. math::
    \begin{aligned}
    i_t &= \sigma (W_{xi}x_t + W_{hi}h_t + b_{i}) \\
    f_t &= \sigma (W_{xf}x_t + W_{hf}h_t + b_{f}) \\
    g_t &= \text{tanh} (W_{xg}x_t + W_{hg}h_t + b_{g}) \\
    o_t &= \sigma (W_{xo}x_t + W_{ho}h_t + b_{o}) \\
    c_{t + 1} &= f_t \odot c_t + i_t \odot g_t \\
    h_{t + 1} &= o_t \text{tanh}(c_{t + 1})
    \end{aligned}

The hidden state :math:`h` and cell state :math:`c` have shape ``NH``
or ``H``, depending on whether the input is batched or not.

The layer returns two arrays, the hidden state and the cell state at
each time step, both of shape ``NLH`` or ``LH``.

Args:
    input_size (int): Dimension of the input, ``D``.
    hidden_size (int): Dimension of the hidden state, ``H``.
    bias (bool): Whether to use biases or not. Default: ``True``.
c                ó,   <€ V ^8„  d   QhRS[ RS[ RS[/# rR   rS   )r   r   s   "€r   r   ÚLSTM.__annotate__ê   s)   ø€ ÷ 
ñ 
áð
ñ ð
ñ ñ	
r   c                ó°  <€ \         SV `  4        W n        R \        P                  ! V4      ,          p\
        P                  P                  V) V^V,          V3R7      V n        \
        P                  P                  V) V^V,          V3R7      V n	        V'       d3   \
        P                  P                  V) V^V,          3R7      V n
        R# RV n
        R# rV   )r   r   r   r"   r#   r$   r%   r&   rW   rX   r   r[   s   &&&& €r   r   ÚLSTM.__init__ê   sÁ   ø€ ô 	‰ÑÔà&ÔØ”d—i’i Ó,Õ,ˆÜ—)‘)×#Ñ#Ø�˜U¨1¨{­?¸JÐ*Gð $ó 
ˆŒô —)‘)×#Ñ#Ø�˜U¨1¨{­?¸KÐ*Hð $ó 
ˆŒ÷
 ô �I‰I×Ñ 5 &¨u¸QÀ½_Ð<NÐÓOð 	Ž	ð ð 	Ž	r   c                óz   € R V P                   P                  ^,           RV P                   RV P                  RJ 2# r^   )rW   r   r   r   r1   s   &r   r2   ÚLSTM._extra_repr   sC   € à˜$Ÿ'™'Ÿ-™-¨Õ*Ð+ð ,Ø×+Ñ+Ð,¨G°D·I±IÀTÐ4IÐ3JðLð	
r   c                ó”  € V P                   e7   \        P                  ! V P                   WP                  P                  4      pMWP                  P                  ,          p. p. p\        VP                  R,          4       EF  pVRVR3,          pVe,   \        P                  ! WrV P                  P                  4      p\        P                  ! V^RR7      w  r‰r«\        P                  ! V4      p\        P                  ! V	4      p	\        P                  ! V
4      p
\        P                  ! V4      pVe   W“,          WŠ,          ,           pMWŠ,          pV\        P                  ! V4      ,          pVP                  V4       VP                  V4       EK  	  \        P                  ! VRR7      \        P                  ! VRR7      3# ra   )r   r$   r9   rW   r:   r;   r   rX   rd   rc   r   r<   r=   )r)   r>   r?   Úcellr@   Úall_cellrA   ÚifgoÚiÚfÚgÚos   &&&&        r   rB   ÚLSTM.__call__  s9  € Ø�9‰9Ò Ü—’˜Ÿ™ A§w¡w§y¡yÓ1‰Aà—G‘G—I‘I•ˆAàˆ
Øˆä˜Ÿ™ �×%ˆCØ�S˜#˜q�[•>ˆDØÒ!Ü—x’x ¨d¯g©g¯i©iÓ8�ÜŸš $¨°Ô3‰JˆA�!ä—
’
˜1“ˆAÜ—
’
˜1“ˆAÜ—’˜“
ˆAÜ—
’
˜1“ˆAàÒØ•x !¥%Õ'‘à•u�ØœŸš ›Õ&ˆFà�O‰O˜DÔ!Ø×Ñ˜f×%ñ% &ô( �xŠx˜
¨Ô,¬b¯hªh°xÀbÔ.IÐIÐIr   )rX   rW   r   r   ro   )NNrE   rN   s   @@r   rq   rq   É   s&   ù‡ € ñ÷@
õ 
ò,
÷Jô Jr   rq   )r"   Útypingr   r   Úmlx.coreÚcorer$   Úmlx.nn.layers.activationsr   Úmlx.nn.layers.baser   r   rP   rq   © r   r   Ú<module>r‡      sD   ðó ß %å Ý *Ý %ôO-ˆ&ô O-ôdi-ˆ&ô i-ôXZJˆ6ö ZJr   