ó
    ›"vj�  ã                   óP  • % S SK r S SKrS SKrS SKrS SKJr  S SKJr  S SKJ	r	J
r
JrJrJrJrJrJrJrJrJrJrJrJr  S SKrSSKJrJrJrJrJr  SSKJr  SSK J!r!  SS	K"J#r#  SS
K$J%r%J&r&J'r'J(r(J)r)  \" S5      r*\" S5      r+\" SSS9r,\" S0 S9r-\\.   \/S'   S$S jr0 " S S\\*\+4   5      r1\Rd                  S\	S\	S\3S\1S\44
S j5       r5\Rd                  S\	S\	S\3S\1S\	4
S j5       r6\" S\1S9r7S\7S\\3\\3\	4   4   S\74S jr8S/4S\7S\9S\74S  jjr:S\1S!\
\1/\74   S\74S" jr;/ S#Qr<g)%é    N)Ú
ContextVar)ÚPath)ÚAnyÚCallableÚDictÚGenericÚIterableÚIteratorÚListÚOptionalÚSequenceÚSetÚTupleÚTypeVarÚUnionÚcasté   )ÚCupyOpsÚNumpyOpsÚOpsÚParamServerÚget_current_ops)Ú	Optimizer)ÚShim)ÚFloatsXd)ÚDATA_VALIDATIONÚconvert_recursiveÚis_xp_arrayÚpartialÚvalidate_fwd_input_outputÚInTÚOutTÚSelfTÚModel)ÚboundÚcontext_operators)ÚdefaultÚmodelÚreturnc                 ó   • U $ ©N© )r(   ÚargsÚkwargss      Ú™C:\Users\johnn\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\thinc/model.pyÚ
empty_initr0   -   s   € Ø€Ló    c                   óJ  • \ rS rSr% SrSr\\S'   \R                  " 5       r
\R                  \S'   \r\\S'   \\S'   \\S'   \\S	'   \\S
'   \\S'   \\\\   4   \S'   \S    \S'   \\   \S'   \\\4   \S'   \\\\   4   \S'   / SQrS0 0 / / 0 0 SS.S\S\S
\\   S\\\\   4   S\\\\   4   S\S    S\\   S\\\4   S\\\S    4   S\\\\4      4S jjr\S\S    4S j5       r\S\\   4S j5       r \S\\\4   4S j5       r!\S\"\S 4   4S! j5       r#\S\"\S 4   4S" j5       r$\S\"\S 4   4S# j5       r%\S\"\S 4   4S$ j5       r&\'\(RR                  S%\\\4   4S& j5       5       r*S\S\\   4S' jr+S\S\4S( jr,S)S*.S\S+\S,\SS4S- jjr-S\S\\   4S. jr.S\S\\   4S/ jr/S\S\4S0 jr0S\S\\   4S1 jr1S\S+\\   SS4S2 jr2S\S\4S3 jr3S\S\4S4 jr4S\S+\SS4S5 jr5S\S\\   4S6 jr6S\S+\SS4S7 jr7S\S\\   4S8 jr8S\SS 4S9 jr9S\S\S    4S: jr:S\S+\S    SS4S; jr;S<\<S=\S\"\=\4   4S> jr>S{S<\\<   S?\\=   SS 4S@ jjr?S<\<S\"\=\\=/\<4   4   4SA jr@S<\<S\=4SB jrASC\BSS4SD jrC\(RR                  S\\"\\4   \4   4SE j5       rDSFSG.SH\S\ES    4SI jjrFS\ES    4SJ jrGS|SK\S\ES    4SL jjrHS}SM jrISSN.S\S
\\   SS4SO jjrJSPS SQS S\4SR jrKS\\"\\4   \"\\4   4   4SS jrLST\MS\M4SU jrN S~ST\MSV\\\\S \4   4      S\M4SW jjrOSX\SS4SY jrPSSZ jrQS\SS4S[ jrRS\S4S\ jrTS]\\U\4   SS4S^ jrVS\4S_ jrWS`\SSS 4Sa jrXS]\\U\4   SS 4Sb jrYSc\SS 4Sd jrZSeSf.S]\\U\4   Sg\S\4Sh jjr[SeSf.S`\SSg\S\4Si jjr\SeSf.Sc\Sg\S\4Sj jjr]Sk\SS 4Sl jr^Sk\SS 4Sm jr_Sk\SS 4Sn jr`Sk\SS 4So jraSk\SS 4Sp jrbSk\SS 4Sq jrcSk\SS 4Sr jrdSk\SS 4Ss jreSk\SS 4St jrfSk\SS 4Su jrgSk\SS 4Sv jrhSk\SS 4Sw jriSk\SS 4Sx jrjSk\SS 4Sy jrkSzrlg)€r$   é1   z/Class for implementing Thinc models and layers.r   Ú	global_idÚglobal_id_lockÚnameÚopsÚidÚ_funcÚinitÚ_paramsÚ_dimsÚ_layersÚ_shimsÚ_attrsÚ_has_params)r6   r8   r7   r9   r:   r;   r<   r?   Ú_refsr=   r>   r@   N)r:   ÚdimsÚparamsÚlayersÚshimsÚattrsÚrefsr7   ÚforwardrB   rC   rD   rE   rF   rG   c                óŠ  • Xl         Uc  [        [        U 5      n[        U SU5        [        U SU5        U
b  U
O	[	        5       U l        [        5       U l        [        U5      U l	        [        U5      U l
        [        U	5      U l        [        U5      U l        [        U5      U l        [        R                      [        =R"                  S-  sl        [        R"                  U l        SSS5        0 U l        UR)                  5        H*  u  pSU R&                  U'   Uc  M  U R+                  X5        M,     g! , (       d  f       NT= f)zInitialize a new model.Nr9   r:   r   )r6   r   r0   Úsetattrr   r7   r   r;   Údictr<   r?   rA   Úlistr=   r>   r$   r5   r4   r8   r@   ÚitemsÚ	set_param)Úselfr6   rH   r:   rB   rC   rD   rE   rF   rG   r7   Úvalues               r/   Ú__init__ÚModel.__init__U   sò   € ð Œ	Ø‰<Üœ: tÓ,ˆDä��g˜wÔ'Ü��f˜dÔ#Ø™/‘3¬Ó/@ˆŒÜ"“}ˆŒÜ˜$“ZˆŒ
Ü˜5“kˆŒÜ˜$“ZˆŒ
Ü˜F“|ˆŒÜ˜5“kˆŒô ×!Ó!Ü�OŠO˜qÑ �OÜ—o‘oˆDŒG÷ "ð ˆÔØ!Ÿ<™<ž>‰KˆDØ%)ˆD×Ñ˜TÑ"ØÓ Ø—‘˜tÖ+ò *÷	 "Õ!ús   Â7/D4Ä4
Er)   c                 ó   • U R                   $ )z]A list of child layers of the model. You can append to it to add
layers but not reassign it.
)r=   ©rO   s    r/   rD   ÚModel.layers|   s   € ð
 �|‰|Ðr1   c                 ó   • U R                   $ r+   )r>   rT   s    r/   rE   ÚModel.shimsƒ   s   € à�{‰{Ðr1   c                 ó   • U R                   $ )zVA dict of the model's attrs. You can write to it to update attrs but
not reassign it.
)r?   rT   s    r/   rF   ÚModel.attrs‡   s   € ð
 �{‰{Ðr1   .c                 óH   • [        U R                  R                  5       5      $ )z8Get the names of registered parameter (including unset).)Útupler@   ÚkeysrT   s    r/   Úparam_namesÚModel.param_namesŽ   s   € ô �T×%Ñ%×*Ñ*Ó,Ó-Ð-r1   c                 ó†   • [        U R                   Vs/ s H  oR                  U5      (       d  M  UPM     sn5      $ s  snf )zHGet the names of parameters with registered gradients (including unset).)r[   r]   Úhas_grad©rO   r6   s     r/   Ú
grad_namesÚModel.grad_names“   s2   € ô  t×'7Ò'7ÓOÒ'7˜t¿=¹=È×;N—dÑ'7ÑOÓPÐPùÒOs   ”>±>c                 óH   • [        U R                  R                  5       5      $ )z9Get the names of registered dimensions (including unset).)r[   r<   r\   rT   s    r/   Ú	dim_namesÚModel.dim_names˜   ó   € ô �T—Z‘Z—_‘_Ó&Ó'Ð'r1   c                 óH   • [        U R                  R                  5       5      $ )z>Get the names of registered node references (including unset).)r[   rA   r\   rT   s    r/   Ú	ref_namesÚModel.ref_names�   rg   r1   Ú	operatorsc              #   ó’   #   • U R                   R                  [        U5      5      nSv •  U R                   R                  U5        g7f)zòBind arbitrary binary functions to Python operators, for use in any
`Model` instance. Can (and should) be used as a contextmanager.

EXAMPLE:
    with Model.define_operators({">>": chain}):
        model = Relu(512) >> Relu(512) >> Softmax()
N)Ú_context_operatorsÚsetrK   Úreset)Úclsrk   Útokens      r/   Údefine_operatorsÚModel.define_operators¢   s8   é € ð ×&Ñ&×*Ñ*¬4°	«?Ó;ˆÛØ×Ñ×$Ñ$ UÕ+ùs   ‚AAc                 óF   • XR                   ;  a  gU R                   U   b  gg)z~Check whether the model has a dimension of a given name. If the
dimension is registered but the value is unset, returns None.
FNT)r<   ra   s     r/   Úhas_dimÚModel.has_dim°   ó&   € ð —z‘zÓ!ØØ�Z‰Z˜ÑÑ)Øàr1   c                 ó¼   • XR                   ;  a  [        SU SU R                   S35      eU R                   U   nUc  SU SU R                   S3n[        U5      eU$ )z4Retrieve the value of a dimension of the given name.zCannot get dimension 'ú' for model 'Ú'z': value unset)r<   ÚKeyErrorr6   Ú
ValueError©rO   r6   rP   Úerrs       r/   Úget_dimÚModel.get_dim»   sf   € à—z‘zÓ!ÜÐ3°D°6¸ÀtÇyÁyÀkÐQRÐSÓTÐTØ—
‘
˜4Ñ ˆØ‰=Ø*¨4¨&°¸d¿i¹i¸[ÈÐWˆCÜ˜S“/Ð!àˆLr1   F)ÚforcerP   r�   c                óš  • XR                   ;  a  [        SU SU R                   S35      eU R                   U   n[        S U R                  R                  5        5       5      nUSL=(       a    XB:g  =(       a    U(       + =(       d    U=(       a    UnU(       a#  SU SU R                   SU SU 3n[        U5      eX R                   U'   g)	zSet a value for a dimension.zCannot set unknown dimension 'ry   ú'.c              3   ó<   #   • U  H  u  p[        U5      v •  M     g 7fr+   )Úbool)Ú.0ÚxÚys      r/   Ú	<genexpr>Ú Model.set_dim.<locals>.<genexpr>Í   s   é € ÐFÒ-E¡T Qœ˜aŸ˜Ò-Eùs   ‚NzAttempt to change dimension 'z' from z to )r<   r{   r6   Úanyr@   rM   r|   )rO   r6   rP   r�   Ú	old_valueÚ
has_paramsÚinvalid_changer~   s           r/   Úset_dimÚModel.set_dimÆ   sÉ   € à—z‘zÓ!ÜØ0°°°mÀDÇIÁIÀ;ÈbÐQóð ð —J‘J˜tÑ$ˆ	ÜÑF¨T×-=Ñ-=×-CÑ-CÔ-EÓFÓFˆ
Ø#¨4Ð/×F°IÑ4F÷ 
ØŒI×-˜×- :ð 	ö Ø1°$°°}ÀTÇYÁYÀKÈwÐW`ÐVaÐaeÐfkÐelÐmˆCÜ˜S“/Ð!Ø �
‰
�4Òr1   c                 óT   • U R                  U5      (       a  U R                  U5      $ S$ )z=Retrieve the value of a dimension of the given name, or None.N)ru   r   ra   s     r/   Úmaybe_get_dimÚModel.maybe_get_dimÖ   ó$   € à%)§\¡\°$×%7Ñ%7ˆt�|‰|˜DÓ!ÐA¸TÐAr1   c                 óF   • XR                   ;  a  gU R                   U   b  gg)z…Check whether the model has a weights parameter of the given name.

Returns None if the parameter is registered but currently unset.
FNT)r@   ra   s     r/   Ú	has_paramÚModel.has_paramÚ   s*   € ð
 ×'Ñ'Ó'ØØ×Ñ˜dÑ#Ñ/Øàr1   c                 ó2  • XR                   ;  a  [        SU SU R                   S35      eU R                  R	                  U R
                  U5      (       d  [        SU SU R                   S35      eU R                  R                  U R
                  U5      $ )z%Retrieve a weights parameter by name.zUnknown param: 'ry   rƒ   zParameter 'z' has not been allocated yet.)r@   r{   r6   r;   r–   r8   Ú	get_paramra   s     r/   r™   ÚModel.get_paramæ   s‰   € à×'Ñ'Ó'ÜÐ-¨d¨V°=ÀÇÁÀÈ2ÐNÓOÐOØ�|‰|×%Ñ% d§g¡g¨t×4Ñ4ÜØ˜d˜V =°·±°Ð;XÐYóð ð �|‰|×%Ñ% d§g¡g¨tÓ4Ð4r1   c                 óT   • U R                  U5      (       a  U R                  U5      $ S$ )z.Retrieve a weights parameter by name, or None.N)r–   r™   ra   s     r/   Úmaybe_get_paramÚModel.maybe_get_paramð   s$   € à'+§~¡~°d×';Ñ';ˆt�~‰~˜dÓ#ÐEÀÐEr1   c                 ó”   • Uc  SU R                   U'   gU R                  R                  U R                  X5        SU R                   U'   g)z Set a weights parameter's value.NT)r@   r;   rN   r8   ©rO   r6   rP   s      r/   rN   ÚModel.set_paramô   s?   € à‰=Ø%)ˆD×Ñ˜TÒ"à�L‰L×"Ñ" 4§7¡7¨DÔ8Ø%)ˆD×Ñ˜TÒ"r1   c                 óN   • U R                   R                  U R                  U5      $ )z@Check whether the model has a non-zero gradient for a parameter.)r;   r`   r8   ra   s     r/   r`   ÚModel.has_gradü   ó   € à�|‰|×$Ñ$ T§W¡W¨dÓ3Ð3r1   c                 óN   • U R                   R                  U R                  U5      $ )zGet a gradient from the model.)r;   Úget_gradr8   ra   s     r/   r¥   ÚModel.get_grad   r£   r1   c                 óP   • U R                   R                  U R                  X5        g)z#Set a gradient value for the model.N)r;   Úset_gradr8   rŸ   s      r/   r¨   ÚModel.set_grad  ó   € à�‰×Ñ˜dŸg™g tÕ3r1   c                 óT   • U R                  U5      (       a  U R                  U5      $ S$ )z%Retrieve a gradient by name, or None.N)r`   r¥   ra   s     r/   Úmaybe_get_gradÚModel.maybe_get_grad  s$   € à&*§m¡m°D×&9Ñ&9ˆt�}‰}˜TÓ"ÐC¸tÐCr1   c                 óP   • U R                   R                  U R                  X5        g)z1Increment the gradient of a parameter by a value.N)r;   Úinc_gradr8   rŸ   s      r/   r¯   ÚModel.inc_grad  rª   r1   c                 óF   • XR                   ;  a  gU R                   U   b  gg)z~Check whether the model has a reference of a given name. If the
reference is registered but the value is unset, returns None.
FNT)rA   ra   s     r/   Úhas_refÚModel.has_ref  rw   r1   c                 ó¼   • XR                   ;  a  [        SU SU R                   S35      eU R                   U   nUc  SU SU R                   S3n[        U5      eU$ )z4Retrieve the value of a reference of the given name.zCannot get reference 'ry   rƒ   z': value unset.)rA   r{   r6   r|   r}   s       r/   Úget_refÚModel.get_ref  sf   € à—z‘zÓ!ÜÐ3°D°6¸ÀtÇyÁyÀkÐQSÐTÓUÐUØ—
‘
˜4Ñ ˆØ‰=Ø*¨4¨&°¸d¿i¹i¸[ÈÐXˆCÜ˜S“/Ð!àˆLr1   c                 óT   • U R                  U5      (       a  U R                  U5      $ S$ )z8Retrieve the value of a reference if it exists, or None.N)r²   rµ   ra   s     r/   Úmaybe_get_refÚModel.maybe_get_ref&  r”   r1   c                 ó€   • Uc  X R                   U'   gX R                  5       ;   a  X R                   U'   g[        S5      e)zSet a value for a reference.Nz)Cannot add reference to node not in tree.)rA   Úwalkr|   rŸ   s      r/   Úset_refÚModel.set_ref*  s7   € à‰=Ø$�J‰J�tÒØ—i‘i“kÓ!Ø$�J‰J�tÒäÐHÓIÐIr1   ÚXÚis_trainc                 ó"   • U R                  XUS9$ )zvCall the model's `forward` function, returning the output and a
callback to compute the gradients via backpropagation.©r¿   ©r9   )rO   r¾   r¿   s      r/   Ú__call__ÚModel.__call__3  s   € ð �z‰z˜$¨HˆzÐ5Ð5r1   ÚYc                 ó¶   • [         R                  " 5       (       a!  [        U R                  U R                  X5        U R
                  b  U R                  XUS9  U $ )z}Finish initialization of the model, optionally providing a batch of
example input and output data to perform shape inference.)r¾   rÅ   )r   Úgetr    r6   r9   r:   )rO   r¾   rÅ   s      r/   Ú
initializeÚModel.initialize8  sF   € ô ×Ò× Ñ Ü% d§i¡i°·±¸QÔBØ�9‰9Ñ Ø�I‰I�d 1ˆIÑ%Øˆr1   c                 ó"   • U R                  XSS9$ )aH  Run the model over a batch of data, returning the output and a
callback to complete the backward pass. A tuple (Y, finish_update),
where Y is a batch of output data, and finish_update is a callback that
takes the gradient with respect to the output and an optimizer function,
and returns the gradient with respect to the input.
TrÁ   rÂ   ©rO   r¾   s     r/   Úbegin_updateÚModel.begin_updateA  s   € ð �z‰z˜$¨DˆzÐ1Ð1r1   c                 ó(   • U R                  XSS9S   $ )z‚Call the model's `forward` function with `is_train=False`, and return
only the output, instead of the `(output, callback)` tuple.
FrÁ   r   rÂ   rË   s     r/   ÚpredictÚModel.predictJ  s   € ð �z‰z˜$¨EˆzÐ2°1Ñ5Ð5r1   Ú	optimizerc           	      óŒ  • U R                  5        H'  nUR                   H  nUR                  U5        M     M)     U R                  5        Hu  nUR                   Hb  nUR	                  U5      (       d  M  U" UR
                  U4UR                  U5      UR                  U5      5      u  pVUR                  XE5        Md     Mw     g)zqUpdate parameters with current gradients. The optimizer is called
with each parameter and gradient of the model.
N)	r»   rE   Úfinish_updater]   r`   r8   r™   r¥   rN   )rO   rÑ   ÚnodeÚshimr6   ÚparamÚgrads          r/   rÓ   ÚModel.finish_updateP  sœ   € ð —I‘I–KˆDØŸ
œ
�Ø×"Ñ" 9Ö-ó #ñ  ð —I‘I–KˆDØ×(Ô(�Ø—=‘= ×&Ó&Ù"+ØŸ™ $˜¨¯©¸Ó)=¸t¿}¹}ÈTÓ?Ró#‘K�Eð —N‘N 4Ö/ó )ò  r1   c              #   óD  #   • 0 nU R                    H?  nU R                  U4nXA;   d  M  U R                  U5      X#'   U R                  X1U   5        MA     [        R
                  " 5        nU R                   H#  nUR                  UR                  U5      5        M%     U R                   H#  nUR                  UR                  U5      5        M%     Sv •  SSS5        U(       a+  UR                  5        H  u  p8U R                  X85        M     gg! , (       d  f       NA= f7f)z©Context manager to temporarily set the model's parameters to
specified values. The params are a dictionary keyed by model IDs, whose
values are arrays of weight values.
N)r]   r8   r™   rN   Ú
contextlibÚ	ExitStackrD   Úenter_contextÚ
use_paramsrE   rM   )	rO   rC   Úbackupr6   ÚkeyÚstackÚlayerrÕ   rÖ   s	            r/   rÝ   ÚModel.use_params_  sâ   é € ð ˆØ×$Ô$ˆDØ—7‘7˜D�/ˆCØ�}Ø#Ÿ~™~¨dÓ3�‘Ø—‘˜t¨C¡[Ö1ñ	 %ô ×!Ò!Ô# uØŸœ�Ø×#Ñ# E×$4Ñ$4°VÓ$<Ö=ñ %àŸ
œ
�Ø×#Ñ# D§O¡O°FÓ$;Ö<ñ #ã÷ $ö Ø%Ÿ|™|ž~‘�Ø—‘˜tÖ+ò  .ð ÷ $Õ#üs$   ‚#D ©A D Á)A+DÃ;D Ä
DÄD Úbfs©Úorderrå   c                ó˜   • US:X  a  U R                  5       $ US:X  a  U R                  SS9$ US:X  a  U R                  SS9$ [        S5      e)zÎIterate out layers of the model.

Nodes are returned in breadth-first order by default. Other possible
orders are "dfs_pre" (depth-first search in preorder) and "dfs_post"
(depth-first search in postorder).rã   Údfs_preF)Ú
post_orderÚdfs_postTz5Invalid order, must be one of: bfs, dfs_pre, dfs_post)Ú	_walk_bfsÚ	_walk_dfsr|   )rO   rå   s     r/   r»   Ú
Model.walkv  sV   € ð �E‹>Ø—>‘>Ó#Ð#Ø�iÓØ—>‘>¨U�>Ð3Ð3Ø�jÓ Ø—>‘>¨T�>Ð2Ð2äÐTÓUÐUr1   c              #   óÌ   #   • U /n[        5       nU HM  n[        U5      U;   a  M  UR                  [        U5      5        Uv •  UR                  UR                  5        MO     g7f)z/Iterate out layers of the model, breadth-first.N)rn   r8   ÚaddÚextendrD   )rO   ÚqueueÚseenrÔ   s       r/   rê   ÚModel._walk_bfs…  sQ   é € à�ˆÜ›ˆÛˆDÜ�$‹x˜4ÓÙØ�H‰H”R˜“XÔØŠJØ�L‰L˜Ÿ™Ö%ò ùs   ‚A"A$rè   c              #   óÊ  #   • [        5       nU /n[        U R                  5      U[        U 5      '   U(       d  U v •  U(       aq   [	        U[        US   5         5      n[        U5      U;  a=  U(       d  Uv •  UR                  U5        [        UR                  5      U[        U5      '   U(       a  Mp  gg! [         a!    U(       a  US   v •  UR                  5          N5f = f7f)z-Iterate out layers of the model, depth-first.éÿÿÿÿN)rK   ÚiterrD   r8   ÚnextÚappendÚStopIterationÚpop)rO   rè   rñ   rà   Ú
next_childs        r/   rë   ÚModel._walk_dfs�  s¶   é € ä-1«VˆØ�ˆÜ˜dŸk™kÓ*ˆŒR�‹X‰ÞØŠJæðÜ! $¤r¨%°©)£}Ñ"5Ó6�
Ü˜*“~¨Ó-Þ%Ø(Ò(à—L‘L Ô,Ü+/°
×0AÑ0AÓ+B�Dœ˜J›Ñ(÷ Šeøô !ó ÞØ ™)’OØ—	‘	–ðüs1   ‚AC#ÁA&B5 Â*C#Â3C#Â5(C ÃC#ÃC Ã C#c                 ó†  • [        U R                  5       5       H@  nXR                  ;   d  M  UR                  R                  U5        XR                  ;   a  M,  MB     [	        U R                  5       5      nU HE  nUR
                   H2  nUR                  U5      nUc  M  XS;  d  M   UR                  US5        M4     MG     g)a5  Remove a node from all layers lists, and then update references.
References that no longer point to a node within the tree will be set
to `None`. For instance, let's say a node has its grandchild as a reference.
If the child is removed, the grandchild reference will be left dangling,
so will be set to None.
N)rL   r»   rD   Úremovern   ri   rµ   r¼   )rO   rÔ   ÚchildÚtreer6   Úrefs         r/   Úremove_nodeÚModel.remove_node¦  s�   € ô ˜$Ÿ)™)›+Ö&ˆEØŸ,™,Õ&Ø—‘×#Ñ# DÔ)ð Ÿ,™,×&ñ 'ô �4—9‘9“;ÓˆÛˆDØŸœ�Ø—l‘l 4Ó(�Ø“? s¥Ø—L‘L  tÖ,ó 'ò r1   )r:   c                ó8   • [        U SU5        [        U SU5        g )Nr9   r:   )rJ   )rO   rH   r:   s      r/   Úreplace_callbacksÚModel.replace_callbacks·  s   € ô 	��g˜wÔ'Ü��f˜dÕ#r1   ÚoldÚnewc                 ó&  • Sn[        U R                  SS95       Hm  nXAL a  SnM  UR                   Vs/ s H  oUUL a  UOUPM     snUl        UR                   H*  nUR	                  U5      UL d  M  UR                  Xb5        M,     Mo     U$ s  snf )zrReplace a node anywhere it occurs within the model. Returns a boolean
indicating whether the replacement was made.Fré   rä   T)rL   r»   r=   ri   rµ   r¼   )rO   r  r  rñ   rÔ   rá   r6   s          r/   Úreplace_nodeÚModel.replace_node½  s”   € ð ˆô
 ˜Ÿ™¨˜Ð4Ö5ˆDØŠ{Ø’ð AEÇÂó Ú@L°u Cš<‘C¨UÒ2Áñ �”ð !ŸNœN�DØ—|‘| DÓ)¨SÔ0ØŸ™ TÖ/ó +ñ 6ð ˆùò s   ´Bc                 óÄ   • 0 nU R                  5        HI  nUR                   H6  nUR                  U5      nUR                  U5      nXE4XR                  U4'   M8     MK     U$ )z‰Get non-zero gradients of the model's parameters, as a dictionary
keyed by the parameter ID. The values are (weights, gradients) tuples.
)r»   rb   r™   r¥   r8   )rO   Ú	gradientsrÔ   r6   rÖ   r×   s         r/   Úget_gradientsÚModel.get_gradientsÒ  s]   € ð ˆ	Ø—I‘I–KˆDØŸœ�ØŸ™ tÓ,�Ø—}‘} TÓ*�Ø.3¨]�	Ÿ7™7 D˜/Ó*ó (ñ  ð
 Ðr1   rO   c                 ó"   • U R                  5       $ )zŸ
Create a copy of the model, its attributes, and its parameters. Any child
layers will also be deep-copied. The copy will receive a distinct `model.id`
value.
)Ú_copyrT   s    r/   ÚcopyÚ
Model.copyÞ  s   € ð �z‰z‹|Ðr1   rñ   c                 ó(  • Uc  0 n0 nU R                    H.  nU R                  U5      (       a  U R                  U5      OS X#'   M0     / nU R                   Hn  n[	        U5      U;   a-  UR                  [        [        U[	        U5         5      5        M?  UR                  U5      nXa[	        U5      '   UR                  U5        Mp     / nU R                   Hm  n[	        U5      U;   a-  UR                  [        [        U[	        U5         5      5        M?  UR                  5       n	X‘[	        U5      '   UR                  U	5        Mo     [        U R                  U R                  U R                  [        R                  " U5      [        R                  " U R                   5      [        R                  " U R"                  5      UUS9n
U R$                   H1  nU
R'                  X0R)                  U5      R                  5       5        M3     [        [*        U
5      $ )N)r:   rC   rB   rF   rD   rE   )r]   r–   r™   rD   r8   r÷   r   r$   r  rE   r   r  r6   r9   r:   Údeepcopyr<   r?   rb   r¨   r¥   r#   )rO   rñ   rC   r6   Úcopied_layersrá   Úcopied_layerÚcopied_shimsrÕ   Úcopied_shimÚcopieds              r/   r  ÚModel._copyæ  s˜  € ð ‰<ØˆDØˆØ×$Ô$ˆDØ37·>±>À$×3GÑ3G˜4Ÿ>™>¨$Ô/ÈTˆF‹Lñ %ð &(ˆØ—[”[ˆEÜ�%‹y˜DÓ Ø×$Ñ$¤T¬%°´b¸³i±Ó%AÖBà$Ÿ{™{¨4Ó0�Ø".”R˜“Y‘Ø×$Ñ$ \Ö2ñ !ð ˆØ—J”JˆDÜ�$‹x˜4ÓØ×#Ñ#¤D¬¨t´B°t³H©~Ó$>Ö?à"Ÿi™i›k�Ø!,”R˜“X‘Ø×#Ñ# KÖ0ñ ô $)Ø�I‰IØ�J‰JØ—‘Ü—=’= Ó(Ü—’˜tŸz™zÓ*Ü—-’- §¡Ó,Ø Øñ	$
ˆð —O”OˆDØ�O‰O˜D§-¡-°Ó"5×":Ñ":Ó"<Ö=ñ $ä”E˜6Ó"Ð"r1   Úgpu_idc                 ó¼   • SSK nUR                  R                  R                  U5         U R	                  [        5       5        SSS5        g! , (       d  f       g= f)z)Transfer the model to a given GPU device.r   N)Úcupy.cuda.deviceÚcudaÚdeviceÚDeviceÚ_to_opsr   )rO   r  Úcupys      r/   Úto_gpuÚModel.to_gpu  s7   € ãà�Y‰Y×Ñ×$Ñ$ VÕ,Ø�L‰Lœ›Ô#÷ -×,Ö,ús   ªAÁ
Ac                 ó6   • U R                  [        5       5        g)zTransfer the model to CPU.N)r!  r   rT   s    r/   Úto_cpuÚModel.to_cpu  s   € à�‰”X“ZÕ r1   c           
      óî  • U R                  5        Há  nXl        UR                   H�  nUR                  U5      (       a/  UR	                  X1R                  UR                  U5      5      5        UR                  U5      (       d  M`  UR                  X1R                  UR                  U5      5      5        M‘     UR                   H)  nUR                  UR                  UR                  5        M+     Mã     g)z Common method for to_cpu/to_gpu.N)r»   r7   r]   r–   rN   Ú	asarray_fr™   r`   r¨   r¥   rE   Ú	to_deviceÚdevice_typeÚ	device_id)rO   r7   rÔ   r6   rÕ   s        r/   r!  ÚModel._to_ops  s§   € à—I‘I–KˆDØŒHØ×(Ô(�Ø—>‘> $×'Ñ'Ø—N‘N 4¯©°t·~±~ÀdÓ7KÓ)LÔMØ—=‘= ×&Ó&Ø—M‘M $¯©°d·m±mÀDÓ6IÓ(JÖKñ	 )ð
 Ÿ
œ
�Ø—‘˜sŸ™°·±Ö>ó #ò  r1   c                 óª   • U R                  5       n[        U R                  R                  SS9n[	        [
        X!5      n[        R                  " U5      $ )a9  Serialize the model to a bytes representation. Models are usually
serialized using msgpack, so you should be able to call msgpack.loads()
on the data and get back a dictionary with the contents.

Serialization should round-trip identically, i.e. the same bytes should
result from loading and serializing a model.
Ú<)Ú
byte_order)Úto_dictr   r7   Úto_numpyr   r   ÚsrslyÚmsgpack_dumps)rO   ÚmsgÚto_numpy_les      r/   Úto_bytesÚModel.to_bytes&  sB   € ð �l‰l‹nˆÜ˜dŸh™h×/Ñ/¸CÑ@ˆÜ¤¨[Ó>ˆÜ×"Ò" 3Ó'Ð'r1   Úpathc                 óÜ   • [        U[        5      (       a  [        U5      OUnUR                  S5       nUR	                  U R                  5       5        SSS5        g! , (       d  f       g= f)z‡Serialize the model to disk. Most models will serialize to a single
file, which should just be the bytes contents of model.to_bytes().
ÚwbN)Ú
isinstanceÚstrr   ÚopenÚwriter7  )rO   r9  Úfile_s      r/   Úto_diskÚModel.to_disk3  sD   € ô (¨¬c×2Ñ2Œt�DŒz¸ˆØ�Y‰Y�tŒ_ Ø�K‰K˜Ÿ™›Ô(÷ �_Ž_ús   ´ AÁ
A+c                 óî  • / / / / S.n[        U R                  5       5      n[        U5       VVs0 s H  u  p4UR                  U_M     nnn[        U5       Hò  u  p40 n/ nUR                   Hc  nUR                  U5      (       d  SXh'   M  UR                  U5      n	U	R                  U;   a  XYR                     Xh'   MR  UR                  U5        Me     U(       a  [        SU 35      e0 n
UR                   H.  nUR                  U5      (       a  UR                  U5      OSX«'   M0     US   R                  X4R                  X¦S.5        Mô     U HK  n0 nUR                  R                  5        H  u  p� [        XÝX„5      XÈ'   M     US   R                  U5        MM     U H?  nUS   R                  UR"                   Vs/ s H  oîR%                  5       PM     sn5        MA     U Hp  n0 nUR&                   HG  nUR)                  U5      (       a*  [+        [,        [.           UR1                  U5      5      Xø'   MC  SXø'   MI     US   R                  U5        Mr     U$ s  snnf ! [          a     GM  f = fs  snf )	z£Serialize the model to a dict representation.

Serialization should round-trip identically, i.e. the same dict should
result from loading and serializing a model.
)ÚnodesrF   rC   rE   NzCannot get references: rD  )Úindexr6   rB   rG   rF   rE   rC   )rL   r»   Ú	enumerater8   ri   r²   rµ   r÷   r|   re   ru   r   r6   rF   rM   Úserialize_attrÚ	TypeErrorrE   r7  r]   r–   r   r   r   r™   )rO   r5  rD  ÚirÔ   Ú	node_to_irG   Úinvalid_refsr6   r   rB   ÚdimrF   rP   rÕ   rC   s                   r/   r1  ÚModel.to_dict;  s:  € ð *,°bÀBÐQSÑTˆÜ�T—Y‘Y“[Ó!ˆô
 09¸Ô/?Ô@Ò/?¡G A�T—W‘W˜a’ZÑ/?ˆ	Ñ@Ü  Ö'‰GˆAØ-/ˆDØ&(ˆLØŸœ�Ø—|‘| D×)Ñ)Ø!%�D“JàŸ,™, tÓ,�CØ—v‘v Ó*Ø%.¯v©vÑ%6˜›
à$×+Ñ+¨DÖ1ñ 'ö Ü Ð#:¸<¸.Ð!IÓJÐJØˆDØ—~”~�Ø15·±¸c×1BÑ1B˜DŸL™L¨Ô-È�“	ñ &à�‰L×ÑØ§Y¡Y¸ÑKöñ# (ó( ˆDØˆEØ#Ÿz™z×/Ñ/Ö1‘�ðÜ"0°¸tÓ"J�E“Kñ  2ð
 �‰L×Ñ Ö&ñ ó ˆDØ�‰L×Ñ¸T¿ZºZÓ HºZ°T§¡¦¹ZÑ HÖIñ ãˆDØ46ˆFØ×(Ô(�Ø—>‘> $×'Ñ'Ü#'¬´Ñ(:¸D¿N¹NÈ4Ó<PÓ#Q�F“Là#'�F“Lñ	 )ð
 �‰M× Ñ  Ö(ñ ð ˆ
ùóO Aøô4 !ó Ûðüò !Is   ¯IÅ3I Æ>I2
É 
I/É.I/Ú
bytes_datac                 óš   • [         R                  " U5      n[        [        U R                  R
                  U5      nU R                  U5      $ )a=  Deserialize the model from a bytes representation. Models are usually
serialized using msgpack, so you should be able to call msgpack.loads()
on the data and get back a dictionary with the contents.

Serialization should round-trip identically, i.e. the same bytes should
result from loading and serializing a model.
)r3  Úmsgpack_loadsr   r   r7   ÚasarrayÚ	from_dict)rO   rN  r5  s      r/   Ú
from_bytesÚModel.from_bytest  s;   € ô ×!Ò! *Ó-ˆÜ¤¨T¯X©X×-=Ñ-=¸sÓCˆØ�~‰~˜cÓ"Ð"r1   c                 óÞ   • [        U[        5      (       a  [        U5      OUnUR                  S5       nUR	                  5       nSSS5        U R                  W5      $ ! , (       d  f       N= f)aŽ  Deserialize the model from disk. Most models will serialize to a single
file, which should just be the bytes contents of model.to_bytes().

The model instance must have the same architecture (layers, dimensions)
as the model that was serialized. For example, if a chain(Relu(10),
Relu(1), Logistic()) model was saved, load it into a model created with
the same chain(...) call, not a bare Model().
ÚrbN)r<  r=  r   r>  ÚreadrS  )rO   r9  r@  rN  s       r/   Ú	from_diskÚModel.from_disk€  sO   € ô (¨¬c×2Ñ2Œt�DŒz¸ˆØ�Y‰Y�tŒ_ ØŸ™›ˆJ÷ à�‰˜zÓ*Ð*÷ �_ús   ´AÁ
A,r5  c                 óØ  • SUR                  5       ;  a  Sn[        U5      e[        U R                  5       5      n[	        US   5      [	        U5      :w  a  [        S5      e[        U5       GHy  u  pEUS   U   nUS   Ul        US   R                  5        H  u  pxUc  M
  UR                  Xx5        M     US   R                  5        H0  u  pšU
c  UR                  U	S 5        M  UR                  X“U
   5        M2     US   U   R                  5        H:  u  p¸UR                  R                  U5      n[        XÈXµ5      nXÕR                  U'   M<     US   U   R                  5        HB  u  pèUb)  UR                  R                  U5      R                  5       nUR!                  Xè5        MD     [        US	   U   5       H#  u  pOUR"                  U   R%                  U5        M%     GM|     U $ )
NrD  zMTrying to read a Model that was created with an incompatible version of Thincz.Cannot deserialize model: mismatched structurer6   rB   rG   rF   rC   rE   )r\   r|   rL   r»   ÚlenrF  r6   rM   r�   r¼   rF   rÇ   Údeserialize_attrr7   rQ  r  rN   rE   rS  )rO   r5  r~   rD  rI  rÔ   ÚinforL  rP   r   Ú	ref_indexÚattrÚdefault_valueÚloaded_valueÚ
param_nameÚ
shim_bytess                   r/   rR  ÚModel.from_dictŽ  sµ  € Ø˜#Ÿ(™(›*Ó$ØaˆCÜ˜S“/Ð!Ü�T—Y‘Y“[Ó!ˆÜˆs�7‰|Ó¤ E£
Ó*ÜÐMÓNÐNÜ  ×'‰GˆAØ�w‘< ‘?ˆDØ˜V™ˆDŒIØ" 6™l×0Ñ0Ö2‘
�ØÓ$Ø—L‘L Ö,ñ 3ð #' v¡,×"4Ñ"4Ö"6‘�ØÑ$Ø—L‘L  dÖ+à—L‘L ¨IÑ&6Ö7ñ	 #7ð
  # 7™|¨A™×4Ñ4Ö6‘�Ø $§
¡
§¡¨tÓ 4�Ü/°ÀdÓQ�Ø#/—
‘
˜4Ó ñ  7ð &)¨¡]°1Ñ%5×%;Ñ%;Ö%=Ñ!�
ØÑ$Ø ŸH™H×,Ñ,¨UÓ3×8Ñ8Ó:�EØ—‘˜zÖ1ñ &>ô "+¨3¨w©<¸©?Ö!;‘�Ø—
‘
˜1‘×(Ñ(¨Ö4ô "<ñ' (ð* ˆr1   T©Ústrictrf  c                ó2  • [        U[        5      (       a  [        U5      OUnUR                  5       (       d  UR	                  5       (       d  gUR                  S5       nUR                  5       nSSS5        U R                  WUS9$ ! , (       d  f       N= f)z°Check whether serialized data on disk is compatible with the model.
If 'strict', the function returns False if the model has an attribute
already loaded that would be changed.
FrV  Nre  )r<  r=  r   Úis_dirÚexistsr>  rW  Úcan_from_bytes)rO   r9  rf  r@  rN  s        r/   Úcan_from_diskÚModel.can_from_disk¬  sn   € ô
 (¨¬c×2Ñ2Œt�DŒz¸ˆØ�;‰;�=‰= §¡§¡ØØ�Y‰Y�tŒ_ ØŸ™›ˆJ÷ à×"Ñ" :°fÐ"Ð=Ð=÷ �_ús   ÁBÂ
Bc                ón   •  [         R                  " U5      nU R                  X2S9$ ! [         a     gf = f)z§Check whether the bytes data is compatible with the model. If 'strict',
the function returns False if the model has an attribute already loaded
that would be changed.
Fre  )r3  rP  r|   Úcan_from_dict)rO   rN  rf  r5  s       r/   rj  ÚModel.can_from_bytes¸  sA   € ð
	Ü×%Ò% jÓ1ˆCð ×!Ñ! #Ð!Ð5Ð5øô ó 	Ùð	ús   ‚' §
4³4c                óê  • SUR                  5       ;  a  g[        U R                  5       5      n[        US   5      [        U5      :w  a  g[	        U5       GHˆ  u  pEUS   U   nU(       a  US   UR
                  :w  a    g[        US   U   5      [        UR                  5      :w  a    gUS   R                  5        H?  u  pxUR                  U5      n	U	SL a      gU	(       d  M'  UR                  U5      U:w  d  M>      g   US   U   R                  5        HZ  u  p¨UR                  U
5      nUSL a      gU(       d  M'  Uc  M,  UR                  U
5      nUR                  UR                  :w  d  MY      g   U(       d  GM(  US   U   R                  5        HF  u  pØXÕR                  ;   d  M   [        UR                  U   UR                  U   XÕ5      nXè:w  d  ME      g   GM‹     g! [         a     M]  f = f)	z¥Check whether a dictionary is compatible with the model.
If 'strict', the function returns False if the model has an attribute
already loaded that would be changed.
rD  Fr6   rE   rB   rC   rF   T)r\   rL   r»   r[  rF  r6   rE   rM   ru   r   r–   r™   ÚshaperF   rG  rH  )rO   r5  rf  rD  rI  rÔ   r]  rL  rP   ru   rb  r–   rÖ   r_  Ú
serializeds                  r/   rn  ÚModel.can_from_dictÃ  s¼  € ð
 ˜#Ÿ(™(›*Ó$ØÜ�T—Y‘Y“[Ó!ˆÜˆs�7‰|Ó¤ E£
Ó*Øä  ×'‰GˆAØ�w‘< ‘?ˆDÞ˜$˜v™,¨$¯)©)Ó3ÙÜ�3�w‘< ‘?Ó#¤s¨4¯:©:£Ó6ñ Ø" 6™l×0Ñ0Ö2‘
�ØŸ,™, sÓ+�Ø˜eÒ#Ú ß�W §¡¨cÓ!2°eÕ!;Ú ñ 3ð &)¨¡]°1Ñ%5×%;Ñ%;Ö%=Ñ!�
Ø ŸN™N¨:Ó6�	Ø Ò%Ú ß�Y 5Ó#4Ø ŸN™N¨:Ó6�EØ—{‘{ e§k¡kÕ1Ú$ñ &>÷ ‰vØ#& w¡<°¡?×#8Ñ#8Ö#:‘K�DØŸz™zÕ)ð%ä)7Ø $§
¡
¨4Ñ 0°$·*±*¸TÑ2BÀDó*˜Jð
 &Õ.Ú#(ô $;ñ/ (ðD øô	  )ó %Ú$ð%ús   Æ+'G$Ç$
G2Ç1G2Úotherc                 óš   • SU R                   R                  5       ;  a  [        S5      eU R                   R                  5       S   " X5      $ )z-Apply the function bound to the '+' operator.Ú+zUndefined operator: +©rm   rÇ   rH  ©rO   rt  s     r/   Ú__add__ÚModel.__add__ò  óD   € à�d×-Ñ-×1Ñ1Ó3Ó3ÜÐ3Ó4Ð4Ø×&Ñ&×*Ñ*Ó,¨SÒ1°$Ó>Ð>r1   c                 óš   • SU R                   R                  5       ;  a  [        S5      eU R                   R                  5       S   " X5      $ )z-Apply the function bound to the '-' operator.Ú-zUndefined operator: -rw  rx  s     r/   Ú__sub__ÚModel.__sub__ø  r{  r1   c                 óš   • SU R                   R                  5       ;  a  [        S5      eU R                   R                  5       S   " X5      $ )z-Apply the function bound to the '*' operator.Ú*zUndefined operator: *rw  rx  s     r/   Ú__mul__ÚModel.__mul__þ  r{  r1   c                 óš   • SU R                   R                  5       ;  a  [        S5      eU R                   R                  5       S   " X5      $ )z-Apply the function bound to the '@' operator.Ú@zUndefined operator: @rw  rx  s     r/   Ú
__matmul__ÚModel.__matmul__  r{  r1   c                 óš   • SU R                   R                  5       ;  a  [        S5      eU R                   R                  5       S   " X5      $ ©z-Apply the function bound to the '/' operator.Ú/zUndefined operator: /rw  rx  s     r/   Ú__div__ÚModel.__div__
  r{  r1   c                 óš   • SU R                   R                  5       ;  a  [        S5      eU R                   R                  5       S   " X5      $ r‰  rw  rx  s     r/   Ú__truediv__ÚModel.__truediv__  r{  r1   c                 óš   • SU R                   R                  5       ;  a  [        S5      eU R                   R                  5       S   " X5      $ )z.Apply the function bound to the '//' operator.z//zUndefined operator: //rw  rx  s     r/   Ú__floordiv__ÚModel.__floordiv__  óD   € à�t×.Ñ.×2Ñ2Ó4Ó4ÜÐ4Ó5Ð5Ø×&Ñ&×*Ñ*Ó,¨TÒ2°4Ó?Ð?r1   c                 óš   • SU R                   R                  5       ;  a  [        S5      eU R                   R                  5       S   " X5      $ )z-Apply the function bound to the '%' operator.Ú%zUndefined operator: %rw  rx  s     r/   Ú__mod__ÚModel.__mod__  r{  r1   c                 óš   • SU R                   R                  5       ;  a  [        S5      eU R                   R                  5       S   " X5      $ )z.Apply the function bound to the '**' operator.z**zUndefined operator: **rw  )rO   rt  r.   s      r/   Ú__pow__ÚModel.__pow__"  r“  r1   c                 óš   • SU R                   R                  5       ;  a  [        S5      eU R                   R                  5       S   " X5      $ )z.Apply the function bound to the '<<' operator.z<<zUndefined operator: <<rw  rx  s     r/   Ú
__lshift__ÚModel.__lshift__(  r“  r1   c                 óš   • SU R                   R                  5       ;  a  [        S5      eU R                   R                  5       S   " X5      $ )z.Apply the function bound to the '>>' operator.z>>zUndefined operator: >>rw  rx  s     r/   Ú
__rshift__ÚModel.__rshift__.  r“  r1   c                 óš   • SU R                   R                  5       ;  a  [        S5      eU R                   R                  5       S   " X5      $ )z-Apply the function bound to the '&' operator.Ú&zUndefined operator: &rw  rx  s     r/   Ú__and__ÚModel.__and__4  r{  r1   c                 óš   • SU R                   R                  5       ;  a  [        S5      eU R                   R                  5       S   " X5      $ )z-Apply the function bound to the '^' operator.Ú^zUndefined operator: ^rw  rx  s     r/   Ú__xor__ÚModel.__xor__:  r{  r1   c                 óš   • SU R                   R                  5       ;  a  [        S5      eU R                   R                  5       S   " X5      $ )z-Apply the function bound to the '|' operator.Ú|zUndefined operator: |rw  rx  s     r/   Ú__or__ÚModel.__or__@  r{  r1   )
r?   r<   r@   r=   r;   rA   r>   r8   r6   r7   )NN)F)rÔ   r$   r)   Nr+   )r)   N)mÚ__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r4   ÚintÚ__annotations__Ú	threadingÚLockr5   r&   rm   r=  r   r   r   r   r   r   r   r   r…   Ú	__slots__r   r   r   r   r   rQ   ÚpropertyrD   rE   rF   r   r]   rb   re   ri   ÚclassmethodrÚ   Úcontextmanagerrr   ru   r   r�   r’   r–   r™   rœ   rN   r`   r¥   r¨   r¬   r¯   r²   rµ   r¸   r¼   r!   r"   rÃ   rÈ   rÌ   rÏ   r   rÓ   rÝ   r	   r»   rê   rë   r  r  r	  r  r#   r  r  r#  r&  r!  Úbytesr7  r   rA  r1  rS  rX  rR  rk  rj  rn  ry  r~  r‚  r†  r‹  rŽ  r‘  r–  r™  rœ  rŸ  r£  r§  r«  Ú__static_attributes__r,   r1   r/   r$   r$   1   s-  ‡ Ù9à€IˆsÓØ%.§^¢^Ó%5€N�I—N‘NÓ5Ø*Ðà
ƒIØ	ƒHØƒGØƒOØ
ƒNØÓØ��X˜c‘]Ð"Ñ#Ó#Ø�'‰]ÓØ�‰JÓØ��c�‰NÓØ�c˜8 D™>Ð)Ñ*Ó*ò€Ið( $(Ø)+Ø02Ø$&ØØ "Ø-/Ø26ò%,àð%,ð ð%,ð
 �xÑ ð%,ð �3˜ ™Ð%Ñ&ð%,ð �S˜( 8Ñ,Ð,Ñ-ð%,ð ˜Ñ!ð%,ð �D‰zð%,ð �C˜�H‰~ð%,ð �3˜ Ñ)Ð)Ñ*ð%,ð �e˜H gÐ-Ñ.Ñ/õ%,ðN ð˜˜W™ó ó ðð ð�t˜D‘zó ó ðð ð�t˜C ˜H‘~ó ó ðð ð.˜U 3¨ 8™_ó .ó ð.ð ðQ˜E # s (™Oó Qó ðQð ð(˜5  c ™?ó (ó ð(ð ð(˜5  c ™?ó (ó ð(ð Ø×Ñð
,¨¨c°8¨mÑ)<ó 
,ó ó ð
,ð	˜Cð 	 H¨T¡Nô 	ð	˜Cð 	 Cô 	ð ?Dò !˜Cð !¨ð !°tð !Èõ !ð B #ð B¨(°3©-ô Bð
˜cð 
 h¨t¡nô 
ð5˜cð 5 hô 5ðF Cð F¨H°XÑ,>ô Fð*˜cð *¨(°8Ñ*<ð *Àô *ð4˜Sð 4 Tô 4ð4˜Sð 4 Xô 4ð4˜Sð 4¨ð 4°dô 4ðD 3ð D¨8°HÑ+=ô Dð4˜Sð 4¨ð 4°dô 4ð	˜Cð 	 H¨T¡Nô 	ð	˜Cð 	 Gô 	ðB #ð B¨(°7Ñ*;ô BðJ˜Cð J¨°Ñ(9ð J¸dô Jð6˜#ð 6¨ð 6°%¸¸h¸Ñ2Gô 6ñ
˜H S™Mð °X¸d±^ð Èwõ ð2˜cð 2 e¨D°(¸D¸6À3¸;Ñ2GÐ,GÑ&Hô 2ð6˜ð 6 ô 6ð0 yð 0°Tô 0ð ×Ñð,  e¨C°¨H¡o°xÐ&?Ñ!@ó ,ó ð,ð, $)ò V˜Sð V¨X°gÑ->õ Vð	&˜8 GÑ,ô 	&ñ Dð °X¸gÑ5Fõ ô,-ð$ @Dò$Øð$Ø*2°8Ñ*<ð$à	õ$ð ð ¨gð ¸$ô ð*
˜t E¨#¨s¨(¡O°U¸8ÀXÐ;MÑ5NÐ$NÑOô 
ð�5ð ˜Uô ð HLñ'#Øð'#Ø# D¨¨e°G¸T°MÑ.BÐ)BÑ$CÑDð'#à	õ'#ðR$˜Sð $ Tô $ô!ð
?˜3ð 
? 4ô 
?ð(˜%ô (ð)˜E $¨ )Ñ,ð )°ô )ð7˜ô 7ðr
# Uð 
#¨wô 
#ð+˜e D¨# IÑ.ð +°7ô +ð˜Tð  gô ð< GKò 
> %¨¨c¨	Ñ"2ð 
>¸tð 
>Ètõ 
>ð CGò 	6¨ð 	6¸4ð 	6È4õ 	6ð :>ò - ð -°$ð -À$õ -ð^?˜Sð ? Wô ?ð?˜Sð ? Wô ?ð?˜Sð ? Wô ?ð? ð ?¨ô ?ð?˜Sð ? Wô ?ð? ð ?¨ô ?ð@ #ð @¨'ô @ð?˜Sð ? Wô ?ð@˜Sð @¨wô @ð@ ð @¨ô @ð@ ð @¨ô @ð?˜Sð ? Wô ?ð?˜Sð ? Wô ?ð?˜Cð ? G÷ ?r1   Ú_rP   r6   c                 ó.   • [         R                  " U5      $ )zÑSerialize an attribute value (defaults to msgpack). You can register
custom serializers using the @serialize_attr.register decorator with the
type to serialize, e.g.: @serialize_attr.register(MyCustomObject).
)r3  r4  ©r¼  rP   r6   r(   s       r/   rG  rG  G  ó   € ô ×Ò˜uÓ%Ð%r1   c                 ó.   • [         R                  " U5      $ )zÛDeserialize an attribute value (defaults to msgpack). You can register
custom deserializers using the @deserialize_attr.register decorator with the
type to deserialize, e.g.: @deserialize_attr.register(MyCustomObject).
)r3  rP  r¾  s       r/   r\  r\  P  r¿  r1   Ú_ModelTÚmappingc                 óä   • U R                  5        H[  nUR                  U;   d  M  XR                     nUR                  5        H$  u  pEXBR                  ;   d  M  XRR                  U'   M&     M]     U $ )zŽWalk over the model's nodes, changing the value of attributes using the
provided mapping, which maps node names to attr names to attr values.
)r»   r6   rM   rF   )r(   rÂ  rÔ   rF   r_  rP   s         r/   Úchange_attr_valuesrÄ  \  s[   € ð —
‘
–ˆØ�9‰9˜ÕØŸI™IÑ&ˆEØ$Ÿ{™{ž}‘�ØŸ:™:Õ%Ø',—J‘J˜tÓ$ó  -ñ ð €Lr1   Údropout_rateÚdropc                 ó„   • U R                  5        H+  nU H"  nXCR                  ;   d  M  XR                  U'   M$     M-     U $ )zŽWalk over the model's nodes, setting the dropout rate. You can specify
one or more attribute names, by default it looks for ["dropout_rate"].
)r»   rF   )r(   rÆ  rF   rÔ   r_  s        r/   Úset_dropout_raterÈ  i  s;   € ð —
‘
–ˆÛˆDØ—z‘zÕ!Ø#'—
‘
˜4Ó ó ñ ð €Lr1   Úwrapperc                 ó€   • [        U R                  5       5       H  nU R                  X!" U5      5        M     U" U 5      $ )zKRecursively wrap a model and its submodules. The model is updated
in-place.)rL   r»   r	  )r(   rÉ  rÔ   s      r/   Úwrap_model_recursiverË  t  s9   € ô �U—Z‘Z“\Ö"ˆØ×Ñ˜4 ¨£Ö/ñ #ñ �5‹>Ðr1   )r$   rG  r\  rÄ  rÈ  rË  )r(   r$   r)   r$   )=rÚ   r  Ú	functoolsr´  Úcontextvarsr   Úpathlibr   Útypingr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r3  Úbackendsr   r   r   r   r   Ú
optimizersr   rE   r   Útypesr   Úutilr   r   r   r   r    r!   r"   r#   r&   rK   r³  r0   r$   Úsingledispatchr=  rº  rG  r\  rÁ  rÄ  ÚfloatrÈ  rË  Ú__all__r,   r1   r/   Ú<module>r×     s¢  ðÜ Û Û Û Ý "Ý ÷÷ ÷ ÷ ó" ç JÕ JÝ !Ý Ý ÷õ ñ ˆeƒn€Ùˆvƒ€Ù�˜wÑ'€á&0Ð1DÈbÑ&QÐ �:˜dÑ#Ó QôôS?ˆG�C˜�IÑô S?ðl ×Ñð&�cð & #ð &¨Sð &¸ð &À5ó &ó ð&ð ×Ñð&˜ð & Cð &¨sð &¸5ð &ÀSó &ó ð&ñ �) 5Ñ
)€ð
˜gð 
°°S¸$¸sÀC¸x¹.Ð5HÑ0Ið 
Ègô 
ð :HÐ8Hñ ˜Gð ¨5ð ÈWõ ð ð °¸%¸À'Ð9IÑ0Jð Èwô ò�r1   