
    i              	           d dl mZmZmZmZ ddlmZ ddlmZ  ed      Z	eZ
 ej                  d      dee	ef   dee	ef   d	ee	ef   fd
       Zd Z	 ddee	e
f   dee	   dee
   d	dfdZy)    )AnyOptionalTupleTypeVar   )registry)ModelInTz
tuplify.v1layer1layer2returnc                     | |f|z   }|D cg c]  }|j                    }}t        ddj                  |      z   dz   t        t        |ddi      S c c}w )zSend a separate copy of the input to each child layer, and join the
    outputs of the children into a tuple on the way out.

    Typically used to provide both modified data and the original input to a
    downstream layer.
    ztuple(z, )nIN)initlayersdims)namer	   jointuplify_forwardr   )r   r   r   layernamess        e/var/www/vps2.regionflexible.com/Desarrollo/venv/lib/python3.12/site-packages/thinc/layers/tuplify.pytuplifyr   
   sb     f&F%+,EUZZ,E,499U##c)D\  -s   Ac                     g }g | j                   D ]0  } |||      \  }}|j                  |       j                  |       2 fd}t        |      |fS )Nc                     t        |       D cg c]  \  }} ||       }}}|d   }|dd  D ]  }||z  }	 |S c c}}w )Nr      )zip)dYsbpdYdXsdXdx	backpropss         r   backprop_tuplifyz)tuplify_forward.<locals>.backprop_tuplify(   sV    $'	3$78&"br"v88Vab' 	B"HB			 9s   <)r   appendtuple)	modelXis_trainYsr   Ybackpropr&   r%   s	           @r   r   r       s`    	BI #Ax(8
		!"#
 9&&&    Nr)   r*   r-   c                 2   |o|m| j                   D ]  }|j                           | j                   d   j                  d      r.| j                  d| j                   d   j	                  d             t        | j                         D ]A  \  }}|(|j                  d      |j                  |||          0|j                  |       C | j                   d   j                  d      r/| j                  d| j                   d   j	                  d             y y )Nr   r   nO)r*   r-   )r*   )r   
initializehas_dimset_dimget_dim	enumerate)r)   r*   r-   r   iis        r   r   r   2   s     	yQY\\ 	E	<<?""4(MM$Q 7 7 =>
 u||, "	E=U]]408qAbE*q!	" ||At$dELLO33D9: %r/   )NN)typingr   r   r   r   configr   r)   r	   r
   OutTr   r   r   r    r/   r   <module>r<      s    0 0  en #s(O%*38_
3: *'& KO;d; (;9A$;	;r/   