+
    NV-j6  ã                   óº  € ^ RI t ^ RIHtHt ^ RIHt ]P                  3R R lltRR]P                  3R R llt	RR]P                  3R	 R
 llt
]P                  3R R lltR t]P                  3R R llt]P                  3R R llt]P                  3R R llt]P                  3R R lltRR]P                  3R R lltR]P                  3R R lltR# )é    N)ÚCallableÚLiteralc                óœ   € V ^8„  d   QhR\         R\        P                  R\        \        P                  .\        P                  3,          /# )é   ÚvalueÚdtypeÚreturn©ÚfloatÚmxÚDtyper   Úarray)Úformats   "Ú\/Volumes/fast/ai/experiments/ui-tars-smoke/.venv/lib/python3.14/site-packages/mlx/nn/init.pyÚ__annotate__r   	   s<   € ÷ ñ ÜðÜŸ™ðäŒr�x‰xˆjœ"Ÿ(™(Ð"Õ#ñó    c                ó   a a€ R VV 3R llpV# )aê  An initializer that returns an array filled with ``value``.

Args:
    value (float): The value to fill the array with.
    dtype (Dtype, optional): The data type of the array. Default:
      ``float32``.

Returns:
    Callable[[array], array]: An initializer that returns an array with the
    same shape as the input, filled with ``value``.

Example:

    >>> init_fn = nn.init.constant(0.5)
    >>> init_fn(mx.zeros((2, 2)))
    array([[0.5, 0.5],
           [0.5, 0.5]], dtype=float32)
c                óX   € V ^8„  d   QhR\         P                  R\         P                  /# ©r   Úar	   ©r   r   )r   s   "r   r   Úconstant.<locals>.__annotate__   s"   € ÷ 4ñ 4”r—x‘xð 4¤B§H¡Hñ 4r   c                 óJ   <€ \         P                  ! V P                  SSR 7      # ©©r   )r   ÚfullÚshape)r   r   r   s   &€€r   ÚinitializerÚconstant.<locals>.initializer   s   ø€ Ü�wŠw�q—w‘w ¨UÔ3Ð3r   © )r   r   r   s   ff r   Úconstantr!   	   s   ù€ ÷,4ñ 4ð Ðr   g        ç      ð?c          
      ó¨   € V ^8„  d   QhR\         R\         R\        P                  R\        \        P                  .\        P                  3,          /# )r   ÚmeanÚstdr   r	   r
   )r   s   "r   r   r   %   sD   € ÷ ñ Ü
ðÜ!ðÜ02·±ðäŒr�x‰xˆjœ"Ÿ(™(Ð"Õ#ñr   c                ó"   a aa€ R VV V3R llpV# )a›  An initializer that returns samples from a normal distribution.

Args:
    mean (float, optional): Mean of the normal distribution. Default:
      ``0.0``.
    std (float, optional): Standard deviation of the normal distribution.
      Default: ``1.0``.
    dtype (Dtype, optional): The data type of the array. Default:
      ``float32``.

Returns:
    Callable[[array], array]: An initializer that returns an array with the
    same shape as the input, filled with samples from a normal distribution.

Example:

    >>> init_fn = nn.init.normal()
    >>> init_fn(mx.zeros((2, 2)))
    array([[-0.982273, -0.534422],
           [0.380709, 0.0645099]], dtype=float32)
c                óX   € V ^8„  d   QhR\         P                  R\         P                  /# r   r   )r   s   "r   r   Únormal.<locals>.__annotate__>   s&   € ÷ Qñ Q”r—x‘xð Q¤B§H¡Hñ Qr   c                 ó^   <€ \         P                  P                  V P                  SSSR 7      # )©r   ÚscaleÚlocr   )r   ÚrandomÚnormalr   )r   r   r$   r%   s   &€€€r   r   Únormal.<locals>.initializer>   s%   ø€ Ü�y‰y×Ñ a§g¡g°S¸dÈ%ÐÓPÐPr   r    )r$   r%   r   r   s   fff r   r.   r.   %   s   ú€ ÷2Qò Qð Ðr   c          
      ó¨   € V ^8„  d   QhR\         R\         R\        P                  R\        \        P                  .\        P                  3,          /# )r   ÚlowÚhighr   r	   r
   )r   s   "r   r   r   D   sD   € ÷ ñ Ü	ðÜ!ðÜ02·±ðäŒr�x‰xˆjœ"Ÿ(™(Ð"Õ#ñr   c                ó"   a aa€ R VVV 3R llpV# )a®  An initializer that returns samples from a uniform distribution.

Args:
    low (float, optional): The lower bound of the uniform distribution.
      Default: ``0.0``.
    high (float, optional): The upper bound of the uniform distribution.
      Default: ``1.0``
    dtype (Dtype, optional): The data type of the array. Default: ``float32``.

Returns:
    Callable[[array], array]: An initializer that returns an array
    with the same shape as the input, filled with samples from a uniform
    distribution

Example:

    >>> init_fn = nn.init.uniform(low=0, high=1)
    >>> init_fn(mx.zeros((2, 2)))
    array([[0.883935, 0.863726],
           [0.617261, 0.417497]], dtype=float32)
c                óX   € V ^8„  d   QhR\         P                  R\         P                  /# r   r   )r   s   "r   r   Úuniform.<locals>.__annotate__]   s&   € ÷ Bñ B”r—x‘xð B¤B§H¡Hñ Br   c                 ó^   <€ \         P                  P                  SSV P                  SR 7      # r   )r   r-   Úuniformr   )r   r   r2   r1   s   &€€€r   r   Úuniform.<locals>.initializer]   s%   ø€ Ü�y‰y× Ñ   d¨A¯G©G¸5Ð ÓAÐAr   r    )r1   r2   r   r   s   fff r   r7   r7   D   s   ú€ ÷2Bò Bð Ðr   c                ó�   € V ^8„  d   QhR\         P                  R\        \         P                  .\         P                  3,          /# ©r   r   r	   )r   r   r   r   )r   s   "r   r   r   c   s2   € ÷ ñ ”B—H‘Hð ¬h¼¿¹°zÄ2Ç8Á8Ð7KÕ.Lñ r   c                ó   a € R V 3R llpV# )a‘  An initializer that returns an identity matrix.

Args:
    dtype (Dtype, optional): The data type of the array. Default:
      ``float32``.

Returns:
    Callable[[array], array]: An initializer that returns an identity
    matrix with the same shape as the input.

Example:

    >>> init_fn = nn.init.identity()
    >>> init_fn(mx.zeros((2, 2)))
    array([[1, 0],
           [0, 1]], dtype=float32)
c                óX   € V ^8„  d   QhR\         P                  R\         P                  /# )r   Úarrr	   r   )r   s   "r   r   Úidentity.<locals>.__annotate__v   s"   € ÷ 3ñ 3œŸ™ð 3¤b§h¡hñ 3r   c                 óü   <€ V P                   ^8w  g*   V P                  ^ ,          V P                  ^,          8w  d   \        RV P                   R24      h\        P                  ! V P                  ^ ,          SR7      # )r   z6The input array must be a square matrix but got shape Ú.)Únr   )Úndimr   Ú
ValueErrorr   Úeye)r=   r   s   &€r   r   Úidentity.<locals>.initializerv   s^   ø€ Ø�8‰8�qŒ=˜CŸI™I a�L¨C¯I©I°a­LÔ8ÜØHÈÏÉÈÐSTÐUóð ô �vŠv˜Ÿ	™	 !�¨EÔ2Ð2r   r    ©r   r   s   f r   ÚidentityrG   c   s   ø€ ÷&3ð 3ð Ðr   c                 ó*  € V P                   ^8  d   \        RV P                    R24      hV P                  R,          pV P                  ^ ,          pV P                   ^8”  d1   ^pV P                  ^R  F  pW4,          pK  	  W,          pW#,          pW3# )r   zPGlorot / He initialization requires at least 2 dimensional input but input with z dimensions.éÿÿÿÿ)rB   rC   r   )ÚxÚfan_inÚfan_outÚreceptive_fieldÚds   &    r   Ú_calculate_fan_in_fan_outrO   €   s‘   € Ø‡v�v�„zÜðØ Ÿv™v˜h lð4ó
ð 	
ð
 �W‰W�R�[€FØ�g‰g�a�j€Gà‡v�v�„zØˆØ—‘˜˜2“ˆAØÕ ŠOñ ð Õ)ˆØÕ+ˆàˆ?Ðr   c                óš   € V ^8„  d   QhR\         P                  R\        \         P                  \        .\         P                  3,          /# r:   ©r   r   r   r   r   )r   s   "r   r   r   •   ó7   € ÷ (ñ (Ü�8‰8ð(äŒr�x‰xœÐ¤§¡Ð)Õ*ñ(r   c                ó   a € RR V 3R lllpV# )aû  A Glorot normal initializer.

This initializer samples from a normal distribution with a standard
deviation computed from the number of input (``fan_in``) and output
(``fan_out``) units according to:

.. math::
    \sigma = \gamma \sqrt{\frac{2.0}{\text{fan\_in} + \text{fan\_out}}}

For more details see the original reference: `Understanding the difficulty
of training deep feedforward neural networks
<https://proceedings.mlr.press/v9/glorot10a.html>`_

Args:
    dtype (Dtype, optional): The data type of the array. Default: ``float32``.

Returns:
    Callable[[array, float], array]: An initializer that returns an array
    with the same shape as the input, filled with samples from the Glorot
    normal distribution.

Example:

    >>> init_fn = nn.init.glorot_normal()
    >>> init_fn(mx.zeros((2, 2)))
    array([[0.191107, 1.61278],
           [-0.150594, -0.363207]], dtype=float32)
    >>> init_fn(mx.zeros((2, 2)), gain=4.0)
    array([[1.89613, -4.53947],
           [4.48095, 0.995016]], dtype=float32)
c                ód   € V ^8„  d   QhR\         P                  R\        R\         P                  /# ©r   r   Úgainr	   ©r   r   r   )r   s   "r   r   Ú#glorot_normal.<locals>.__annotate__¸   s.   € ÷ Gñ G”r—x‘xð G¤uð G´r·x±xñ Gr   c                 óÊ   <€ \        V 4      w  r#V\        P                  ! R W#,           ,          4      ,          p\        P                  P                  V P                  VSR7      # )g       @©r   r+   r   )rO   ÚmathÚsqrtr   r-   r.   r   )r   rV   rK   rL   r%   r   s   &&   €r   r   Ú"glorot_normal.<locals>.initializer¸   sJ   ø€ Ü3°AÓ6‰ˆØ”T—Y’Y˜s fÕ&6Õ7Ó8Õ8ˆÜ�y‰y×Ñ a§g¡g°SÀÐÓFÐFr   ©r"   r    rF   s   f r   Úglorot_normalr_   •   s   ø€ ÷FGò Gð
 Ðr   c                óš   € V ^8„  d   QhR\         P                  R\        \         P                  \        .\         P                  3,          /# r:   rQ   )r   s   "r   r   r   À   rR   r   c                ó   a € RR V 3R lllpV# )aõ  A Glorot uniform initializer.

This initializer samples from a uniform distribution with a range
computed from the number of input (``fan_in``) and output (``fan_out``)
units according to:

.. math::
    \sigma = \gamma \sqrt{\frac{6.0}{\text{fan\_in} + \text{fan\_out}}}

For more details see the original reference: `Understanding the difficulty
of training deep feedforward neural networks
<https://proceedings.mlr.press/v9/glorot10a.html>`_

Args:
    dtype (Dtype, optional): The data type of the array. Default: ``float32``.

Returns:
    Callable[[array, float], array]: An initializer that returns an array
    with the same shape as the input, filled with samples from the Glorot
    uniform distribution.

Example:

    >>> init_fn = nn.init.glorot_uniform()
    >>> init_fn(mx.zeros((2, 2)))
    array([[0.223404, -0.890597],
           [-0.379159, -0.776856]], dtype=float32)
    >>> init_fn(mx.zeros((2, 2)), gain=4.0)
    array([[-1.90041, 3.02264],
           [-0.912766, 4.12451]], dtype=float32)
c                ód   € V ^8„  d   QhR\         P                  R\        R\         P                  /# rU   rW   )r   s   "r   r   Ú$glorot_uniform.<locals>.__annotate__ã   s.   € ÷ Fñ F”r—x‘xð F¤uð F´r·x±xñ Fr   c                 óÌ   <€ \        V 4      w  r#V\        P                  ! R W#,           ,          4      ,          p\        P                  P                  V) W@P                  SR7      # )g      @r   )rO   r[   r\   r   r-   r7   r   )r   rV   rK   rL   Úlimitr   s   &&   €r   r   Ú#glorot_uniform.<locals>.initializerã   sL   ø€ Ü3°AÓ6‰ˆØ”t—y’y ¨Õ(8Õ!9Ó:Õ:ˆÜ�y‰y× Ñ  % ¨·±¸uÐ ÓEÐEr   r^   r    rF   s   f r   Úglorot_uniformrg   À   s   ø€ ÷FFò Fð
 Ðr   c                ó²   € V ^8„  d   QhR\         P                  R\        \         P                  \        R,          \
        .\         P                  3,          /# ©r   r   r	   ©rK   rL   ©r   r   r   r   r   r   )r   s   "r   r   r   ë   s?   € ÷ 7ñ 7Ü�8‰8ð7äŒr�x‰xœÐ!4Õ5´uÐ=¼r¿x¹xÐGÕHñ7r   c                ó   a € RR V 3R lllpV# )a–  Build a He normal initializer.

This initializer samples from a normal distribution with a standard
deviation computed from the number of input (``fan_in``) or output
(``fan_out``) units according to:

.. math::
    \sigma = \gamma \frac{1}{\sqrt{\text{fan}}}

where :math:`\text{fan}` is either the number of input units when the
``mode`` is ``"fan_in"`` or output units when the ``mode`` is
``"fan_out"``.

For more details see the original reference: `Delving Deep into Rectifiers:
Surpassing Human-Level Performance on ImageNet Classification
<https://arxiv.org/abs/1502.01852>`_

Args:
    dtype (Dtype, optional): The data type of the array. Default: ``float32``.

Returns:
    Callable[[array, str, float], array]: An initializer that returns an
    array with the same shape as the input, filled with samples from the He
    normal distribution.

Example:

    >>> init_fn = nn.init.he_normal()
    >>> init_fn(mx.zeros((2, 2)))  # uses fan_in
    array([[-1.25211, 0.458835],
           [-0.177208, -0.0137595]], dtype=float32)
    >>> init_fn(mx.zeros((2, 2)), mode="fan_out", gain=5)
    array([[5.6967, 4.02765],
           [-4.15268, -2.75787]], dtype=float32)
c                ó~   € V ^8„  d   QhR\         P                  R\        R,          R\        R\         P                  /# ©r   r   ÚmoderV   r	   rj   ©r   r   r   r   )r   s   "r   r   Úhe_normal.<locals>.__annotate__  sD   € ÷ Gñ GÜ�8‰8ðGäÐ)Õ*ðGô ðGô 
�‰ñ	Gr   c                 óö   <€ \        V 4      w  r4VR 8X  d   TpMVR8X  d   TpM\        RV R24      hV\        P                  ! V4      ,          p\        P
                  P                  V P                  VSR7      # )rK   rL   úInvalid mode: ú". Valid modes are: fan_in, fan_outrZ   )rO   rC   r[   r\   r   r-   r.   r   )r   ro   rV   rK   rL   Úfanr%   r   s   &&&    €r   r   Úhe_normal.<locals>.initializer  sr   ø€ ô
 4°AÓ6‰ˆØ�8ÔØ‰CØ�YÔØ‰Cä˜~¨d¨VÐ3UÐVÓWÐWà”T—Y’Y˜s“^Õ#ˆÜ�y‰y×Ñ a§g¡g°SÀÐÓFÐFr   ©rK   r"   r    rF   s   f r   Ú	he_normalrx   ë   s   ø€ ÷NGò Gð  Ðr   c                ó²   € V ^8„  d   QhR\         P                  R\        \         P                  \        R,          \
        .\         P                  3,          /# ri   rk   )r   s   "r   r   r   %  s?   € ÷ 9ñ 9Ü�8‰8ð9äŒr�x‰xœÐ!4Õ5´uÐ=¼r¿x¹xÐGÕHñ9r   c                ó   a € RR V 3R lllpV# )aŸ  A He uniform (Kaiming uniform) initializer.

This initializer samples from a uniform distribution with a range
computed from the number of input (``fan_in``) or output (``fan_out``)
units according to:

.. math::

    \sigma = \gamma \sqrt{\frac{3.0}{\text{fan}}}

where :math:`\text{fan}` is either the number of input units when the
``mode`` is ``"fan_in"`` or output units when the ``mode`` is
``"fan_out"``.

For more details see the original reference: `Delving Deep into Rectifiers:
Surpassing Human-Level Performance on ImageNet Classification
<https://arxiv.org/abs/1502.01852>`_


Args:
    dtype (Dtype, optional): The data type of the array. Default: ``float32``.

Returns:
    Callable[[array, str, float], array]: An initializer that returns an
    array with the same shape as the input, filled with samples from  the
    He uniform distribution.

Example:

    >>> init_fn = nn.init.he_uniform()
    >>> init_fn(mx.zeros((2, 2)))  # uses fan_in
    array([[0.0300242, -0.0184009],
           [0.793615, 0.666329]], dtype=float32)
    >>> init_fn(mx.zeros((2, 2)), mode="fan_out", gain=5)
    array([[-1.64331, -2.16506],
           [1.08619, 5.79854]], dtype=float32)
c                ó~   € V ^8„  d   QhR\         P                  R\        R,          R\        R\         P                  /# rn   rp   )r   s   "r   r   Ú he_uniform.<locals>.__annotate__N  sD   € ÷ Fñ FÜ�8‰8ðFäÐ)Õ*ðFô ðFô 
�‰ñ	Fr   c                 ó  <€ \        V 4      w  r4VR 8X  d   TpMVR8X  d   TpM\        RV R24      hV\        P                  ! RV,          4      ,          p\        P
                  P                  V) W`P                  SR7      # )rK   rL   rs   rt   g      @r   )rO   rC   r[   r\   r   r-   r7   r   )r   ro   rV   rK   rL   ru   re   r   s   &&&    €r   r   Úhe_uniform.<locals>.initializerN  sy   ø€ ô
 4°AÓ6‰ˆØ�8ÔØ‰CØ�YÔØ‰Cä˜~¨d¨VÐ3UÐVÓWÐWà”t—y’y  s¥Ó+Õ+ˆÜ�y‰y× Ñ  % ¨·±¸uÐ ÓEÐEr   rw   r    rF   s   f r   Ú
he_uniformr   %  s   ø€ ÷RFò Fð  Ðr   c                ó´   € V ^8„  d   QhR\         R\         R\         R\        P                  R\        \        P                  .\        P                  3,          /# )r   Úsparsityr$   r%   r   r	   r
   )r   s   "r   r   r   a  sR   € ÷ ,ñ ,Üð,ä
ð,ô 
ð,ô �8‰8ð	,ô
 Œr�x‰xˆjœ"Ÿ(™(Ð"Õ#ñ,r   c                ó&   a aaa€ R VVV V3R llpV# )aÑ  An initializer that returns a sparse matrix.

Args:
    sparsity (float): The fraction of elements in each column to be set to
    zero.
    mean (float, optional): Mean of the normal distribution. Default:
      ``0.0``.
    std (float, optional): Standard deviation of the normal distribution.
      Default: ``1.0``.
    dtype (Dtype, optional): The data type of the array. Default:
      ``float32``.

Returns:
    Callable[[array], array]: An initializer that returns an array with the
    same shape as the input, filled with samples from a normal distribution.

Example:

    >>> init_fn = nn.init.sparse(sparsity=0.5)
    >>> init_fn(mx.zeros((2, 2)))
    array([[-1.91187, -0.117483],
   [0, 0]], dtype=float32)
c                óX   € V ^8„  d   QhR\         P                  R\         P                  /# r   r   )r   s   "r   r   Úsparse.<locals>.__annotate__  s"   € ÷ ñ ”r—x‘xð ¤B§H¡Hñ r   c                 óî  <€ V P                   ^8w  d   \        R4      hV P                  w  r\        \        P
                  ! SV,          4      4      p\        P                  ! \        P                  P                  V P                  R7      ^R7      p\        P                  P                  V P                  SSSR7      p ^ V \        P                  ! V4      P                  V^4      VRRV13,          3&   V # )r   z,Only tensors with 2 dimensions are supported©r   )Úaxisr*   :NNNN)rB   rC   r   Úintr[   Úceilr   Úargsortr-   r7   r.   ÚarangeÚreshape)	r   ÚrowsÚcolsÚ	num_zerosÚorderr   r$   r�   r%   s	   &    €€€€r   r   Úsparse.<locals>.initializer  s¹   ø€ Ø�6‰6�QŒ;ÜÐKÓLÐLà—W‘W‰
ˆÜœŸ	š	 (¨T¥/Ó2Ó3ˆ	ä—
’
œ2Ÿ9™9×,Ñ,°1·7±7Ð,Ó;À!ÔDˆÜ�I‰I×Ñ 1§7¡7°#¸4ÀuÐÓMˆàDEˆŒ"�)Š)�D‹/×
!Ñ
! $¨Ó
*¨E°!°Z°i°Z°-Õ,@Ð
@ÑAàˆr   r    )r�   r$   r%   r   r   s   ffff r   Úsparser’   a  s   û€ ÷<ó ð Ðr   c                óœ   € V ^8„  d   QhR\         R\        P                  R\        \        P                  .\        P                  3,          /# )r   rV   r   r	   r
   )r   s   "r   r   r   �  s<   € ÷ )ñ )Ü
ð)Ü Ÿh™hð)äŒr�x‰xˆjœ"Ÿ(™(Ð"Õ#ñ)r   c                ó   a a€ R VV 3R llpV# )ac  An initializer that returns an orthogonal matrix.

Args:
    gain (float, optional): Scaling factor for the orthogonal matrix.
        Default: ``1.0``.
    dtype (Dtype, optional): Data type of the array. Default: ``float32``.

Returns:
    Callable[[array], array]: An initializer that returns
    an orthogonal matrix with the same shape as the input.
c                óX   € V ^8„  d   QhR\         P                  R\         P                  /# r   r   )r   s   "r   r   Ú orthogonal.<locals>.__annotate__Ÿ  s"   € ÷ ñ ”r—x‘xð ¤B§H¡Hñ r   c                 óÊ  <€ V P                   ^8w  d   \        R4      hV P                  w  r\        W4      p\        P
                  P                  W33R7      p\        P                  P                  V\        P                  R7      w  rV\        P                  ! V4      pV\        P                  ! V4      ,          pVRV1RV13,          pVS	,          pVP                  S4      # )r   zHOrthogonal initialization requires a 2D array but got a {a.ndim}D array.r†   )ÚstreamN)rB   rC   r   Úmaxr   r-   r.   ÚlinalgÚqrÚcpuÚdiagÚsignÚastype)
r   r�   rŽ   rA   ÚrmatÚqÚrrN   r   rV   s
   &       €€r   r   Úorthogonal.<locals>.initializerŸ  s½   ø€ Ø�6‰6�QŒ;Üð&óð ð
 —W‘W‰
ˆÜ�‹Oˆä�y‰y×Ñ q fÐÓ-ˆô �y‰y�|‰|˜D¬¯©ˆ|Ó0‰ˆô �GŠG�A‹JˆØ”—’˜“
�Nˆð ˆeˆtˆe�U�d�Uˆl�Oˆð ��HˆØ�x‰x˜‹Ðr   r    )rV   r   r   s   ff r   Ú
orthogonalr¤   �  s   ù€ ÷ñ ð4 Ðr   )r[   Útypingr   r   Úmlx.coreÚcorer   Úfloat32r!   r.   r7   rG   rO   r_   rg   rx   r   r’   r¤   r    r   r   Ú<module>r©      s¼   ðó ß $å ð %'§J¡J÷ð:  C¸2¿:¹:÷ð@  C¸2¿:¹:÷ð>  "Ÿz™z÷ ò:ð, —j‘j÷(ðX —j‘j÷(ðX —j‘j÷7ðv —j‘j÷9ð| ØØ—j‘j÷	,ð` ¨¯©÷)ñ )r   