
    h                         S SK JrJrJrJr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JrJr  SSKJrJr  \\\   \\4   r\r\\   r\r\R2                  " S5      0 S S4S	\\\4   S
\S\S\\\4   4S jj5       rS\\\4   S\S\S\\\4   4S jr\R2                  " S5        SSS.S	\\\\\4   \\\4   4      S
\S\\   S\\\4   4S jjj5       rS\\\4   S\S\S\\\4   4S jr g)    )	AnyCallableDictHashableOptionalSequenceTupleUnioncast   )registry)Model)DTypesInts1dInts2d)is_xp_arrayto_numpyzremap_ids.v1imapping_tabledefaultdtypereturnc                 &    [        S[        XUS.S9$ )zRemap string or integer inputs using a mapping table, usually as a
preprocess before embeddings. The mapping table can be passed in on input,
or updated after the layer has been created. The mapping table is stored in
the "mapping_table" attribute.
	remap_ids)r   r   r   attrs)r   forward)r   r   r   s      P/home/james-whalen/.local/lib/python3.13/site-packages/thinc/layers/remap_ids.pyr   r      s      -'R     modelinputsis_trainc                 :   U R                   S   nU R                   S   nU R                   S   nU Vs/ s H  ocR                  Xd5      PM     nnU R                  R                  XuS9nU R                  R	                  USS5      n	S[
        S[        4S	 jn
X4$ s  snf )
Nr   r   r   r      dYr   c                     / $ N )r'   s    r   backpropforward.<locals>.backprop)   s    	r   )r   getops	asarray2i	reshape2iOutT_v1InT)r    r!   r"   tabler   r   xvaluesarroutputr+   s              r   r   r      s     KK(Ekk)$GKK E-34Vii#VF4
))

f

2CYY  b!,FW    5s   Bzremap_ids.v2N)columnr8   c                &    [        S[        XUS.S9$ )a  Remap string or integer inputs using a mapping table,
usually as a preprocessing step before embeddings.
The mapping table can be passed in on input,
or updated after the layer has been created.
The mapping table is stored in the "mapping_table" attribute.
Two dimensional arrays can be provided as input in which case
the 'column' chooses which column to process. This is useful
to work together with FeatureExtractor in spaCy.
r   r   r   r8   r   )r   
forward_v2r:   s      r   remap_ids_v2r<   /   s       -VT r   c                   ^ ^ T R                   S   nUc  [        S5      eT R                   S   nT R                   S   n[        U5      (       a2  SmUb!  [        [	        [
        U5      S S 2U4   5      nO[        U5      nOSmUnU Vs/ s H  osR                  Xt5      PM     nnT R                  R                  USS9n	T R                  R                  U	S	S
5      n
S[        S[        4U U4S jjnX4$ s  snf )Nr   z'mapping table' not setr   r8   TFr   r$   r%   r&   r'   r   c                 t   > T(       a/  TR                   R                  R                  U R                  5      $ / $ r)   )r.   xpemptyshape)r'   r    xp_inputs    r   r+   forward_v2.<locals>.backprop[   s(    99<<%%bhh//Ir   )r   
ValueErrorr   r   r   r   r-   r.   r/   r0   OutTr2   )r    r!   r"   r3   r   r8   idxr4   r5   r6   r7   r+   rB   s   `           @r   r;   r;   F   s     KK(E}233kk)$G[["F64/6	:;C6"C-01Sii#SF1
))

fC

0CYY  b!,FT c    2s   C3)Nr   )!typingr   r   r   r   r   r   r	   r
   r   configr   r    r   typesr   r   r   utilr   r   r2   rE   InT_v1r1   layersintr   boolr   strr<   r;   r*   r   r   <module>rP      s   X X X   * * (HX./	#
 
 $&q#S>14AG
67? !!+1=A
4>  
 EI !	E$sCx.$sCx."@AB SM	
 39 !,d%(48
4>r   