
    i              	           d dl mZ d dlmZ d dlmZ ddlmZ dededeee   ee   f   fd	Z	ddefdZ
dedee   defdZy
)    )List)Model)Floats2d   )DocnMnCreturnc           
      F    t        dt        t        | || |z  dddd i      S )N	charembed   )r   r	   nOnVE)initdimsparams)r   forwardr   )r   r	   s     j/var/www/vps2.regionflexible.com/Desarrollo/venv/lib/python3.12/site-packages/spacy/ml/_character_embed.pyCharacterEmbedr   	   s/    bRs;T{     Nmodelc                     | j                   j                  | j                  d      | j                  d      | j                  d            }| j                  d|       y )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                 ^   	
 |g S g 
g } j                  d      	 j                  d       j                  d       j                  d      } j                  j                  j	                        |D ]  } j                  j                  |j                              } j                  j                  t        |            }	|d d f   f   |d d f<   |j                  |j                  t        |      |f             
j                  |        	
 fd}||fS )Nr   r	   r   r   )nr_charc                 *   j                   j                  j                  j                        }t	        |       D ]?  \  }}|j                  t        |      	f      }||d d f   fxx   |d d f   z  cc<   A j                  d|       g S )N)dtyper   )r   allocshaper&   zipreshapeleninc_grad)
d_outputdEdoc_idsd_doc_vectorsr   idsr   r	   nCvr   s
       r   backpropzforward.<locals>.backprop2   s    YY__QWWAGG_4&)#x&8 	>"G])113w<R2HIMsGAsFO#$af(==$	> 	sB	r   )	get_paramr   r   xparangeasarrayto_utf8_arrayr   r+   appendr*   )r   r!   r"   outputr   docr/   doc_vectorsr3   r   r1   r	   r2   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  8r   )NN)typingr   	thinc.apir   thinc.typesr   tokensr   intr   r   boolr    r   r   <module>rD      sg        s  d3ih.G(H ( (5 S	 T r   