+
    &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   "o/Users/jameslopez/projects/CWCArchive/cwc-podcast/.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0D))**@aP  dii,,&99$$U
*C % 
 99$$U*D % 

  II5&uN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    $((..+, -++, - --.gdiit6K5L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    99 Axxzz2AHHJJA
%C!!CaK.&((**E3Q;&&v.Ff% & xx
,,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     	&dii,,))##U1{?J*G $ 
 ))##U1{?K*H $ 

  II5&uQ_<NO 	  II5&uN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    $''--*+ ,++,GDFF$4F3G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   WP                  ,          p
Wy,           p\        P                  ! V4      p\        P                  ! V^RR7      w  rVRVR3,          pVe   WX
,          ,           pM'V P                  e   WV 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   66GGII.AGGIIA))))))*d&&&(()
%Cc3k"B!''))+"3(;4+;+;*;(;#;<	!#(8(8'8':":;88'(H^BB88B+DACaK A!H$%DHH$
A!a%1qz1a%1f%; &> xx
,,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     	&dii,,))##U1{?J*G $ 
 ))##U1{?K*H $ 

  II5&uQ_<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    $''--*+ ,++,GDIIT4I3J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  rr\        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   99 Awwyy1AGGIIA
%CS#q[>D!xxdggii8$3JA!

1A

1A
A

1Ax!%'u&FOOD!f%% &( xx
,bhhxb.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   