
    i                         d dl mZmZmZmZmZmZmZmZm	Z	 ddl
mZ ddlmZ ddlmZmZmZ ddlmZmZ eee   eef   ZeZee   ZeZ ej2                  d      i d dfd	eeef   d
ededeeef   fd       Zdeeef   dededeeef   fdZ ej2                  d      	 	 dddd	eeeeef   eeef   f      d
edee   deeef   fd       Zdeeef   dededeeef   fdZ y)    )	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                 .    t        dt        | ||d      S )a	  Remap 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      g/var/www/vps2.regionflexible.com/Desarrollo/venv/lib/python3.12/site-packages/thinc/layers/remap_ids.pyr   r      s!      -'R     modelinputsis_trainc                 @   | j                   d   }| j                   d   }| j                   d   }|D cg c]  }|j                  ||       }}| j                  j                  ||      }| j                  j	                  |dd      }	dt
        dt        fd	}
|	|
fS c c}w )
Nr   r   r   r      dYr   c                     g S N )r'   s    r   backpropz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4eii7#4F4
))

fE

2CYY  b!,FW   8 5s   Bzremap_ids.v2N)columnr7   c                .    t        dt        | ||d      S )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   r7   r   )r   
forward_v2r9   s      r   remap_ids_v2r;   /   s!       -'VT r   c                      j                   d   }|t        d       j                   d   } j                   d   }t        |      r1d|!t        t	        t
        |      d d |f         }nt        |      }nd|}|D cg c]  }|j                  ||       }} j                  j                  |d      }	 j                  j                  |	d	d
      }
dt        dt        f fd}|
|fS c c}w )Nr   z'mapping table' not setr   r7   TFr   r$   r%   r&   r'   r   c                 j    r/j                   j                  j                  | j                        S g S r)   )r-   xpemptyshape)r'   r    xp_inputs    r   r+   zforward_v2.<locals>.backprop[   s(    99<<%%bhh//Ir   )r   
ValueErrorr   r   r   r   r,   r-   r.   r/   OutTr1   )r    r!   r"   r2   r   r7   idxr3   r4   r5   r6   r+   rA   s   `           @r   r:   r:   F   s     KK(E}233kk)$G[["F64/6	:;C6"C-01eii7#1F1
))

fC

0CYY  b!,FT c  8 2s   C-)Nr   )!typingr   r   r   r   r   r   r	   r
   r   configr   r    r   typesr   r   r   utilr   r   r1   rC   InT_v1r0   layersintr   boolr   strr;   r:   r*   r   r   <module>rN      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   