
    h              	           S SK Jr  S SKJr  S SKJr  SSKJr  SSKJ	r	  S\
S\
S	\\\   \\   4   4S
 jrSS\4S jjrS\S\\   S\4S jrg)    )List)Model)Floats2d   )Doc)registrynMnCreturnc           
      <    [        S[        [        XX-  SS.SS 0S9$ )N	charembed   )r	   r
   nOnVE)initdimsparams)r   forwardr   )r	   r
   s     S/home/james-whalen/.local/lib/python3.13/site-packages/spacy/ml/_character_embed.pyCharacterEmbedr   
   s+    s;T{     Nmodelc                     U R                   R                  U R                  S5      U R                  S5      U R                  S5      5      nU R                  SU5        g )Nr
   r   r	   r   )opsalloc3fget_dim	set_param)r   XYvectors_tables       r   r   r      sH    II%%dU]]40%--2EM 
OOC'r   docsis_trainc                 ^  ^ ^	^
^^^ Uc  / $ / m
/ nT R                  S5      m	T R                  S5      mT R                  S5      mT R                  S5      nT R                  R                  R	                  T5      mU H  nT R                  R                  UR                  TS95      nT R                  R                  [        U5      TT5      nT	TUS S 2T4   4   US S 2T4'   UR                  UR                  [        U5      U45      5        T
R                  U5        M     U	U
U UUU4S jnX84$ )Nr   r
   r	   r   )nr_charc                 &  > TR                   R                  TR                  TR                  S9n[	        TU 5       H?  u  p#UR                  [        U5      TT	45      nUTUS S 2T4   4==   US S 2T4   -  ss'   MA     TR                  SU5        / $ )N)dtyper   )r   allocshaper'   zipreshapeleninc_grad)
d_outputdEdoc_idsd_doc_vectorsr   idsr   r
   nCvr	   s
       r   backpropforward.<locals>.backprop3   s    YY__QWWAGG_4&)#x&8"G)113w<R2HIMsGAsFO#$af(==$ '9 	sB	r   )	get_paramr   r   xparangeasarrayto_utf8_arrayr   r,   appendr+   )r   r"   r#   outputr   docr0   doc_vectorsr4   r   r2   r
   r3   r	   s   `        @@@@@r   r   r      s   |	
CFA	t	B	t	B	t	B )),,

b
!C))##C$5$5b$5$ABii''C"b9  WQV_ 45AsFk))3s8R.9:

7   r   )NN)typingr   	thinc.apir   thinc.typesr   tokensr   utilr   intr   r   boolr    r   r   <module>rG      sj         s  d3ih.G(H ( (5 S	 T r   