
    ht              
       p   S SK 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  SSKJr  \" S5      r\" S5      r\" S	5      r\
R(                  " S
5      S\S\4S j5       rS\\\4   S\\\4   S\\\4   S\\\4   4S jrS\\\4   S\S\S\\\4   4S jr  SS\\\4   S\\   S\\   SS4S jjrg)    )AnyCallableDictListOptionalTupleTypeVarcast   )registry)Model)
XY_YZ_OutT)	get_widthInTMidTOutTzchain.v1layerreturnc                      [        U 6 $ N)chain)r   s    L/home/james-whalen/.local/lib/python3.13/site-packages/thinc/layers/chain.pychain_no_typesr      s    %=    layer1layer2layersc                 x   X/nUR                  U5        SS0nUS   R                  S5      SL a  US   R                  S5      US'   US   R                  S5      c  SUS'   US   R                  S5      SL a  US   R                  S5      US'   [        SR	                  S U 5       5      [
        [        UUS	9nU$ )
zCompose two models `f` and `g` such that they become layers of a single
feed-forward model that computes `g(f(x))`.
Also supports chaining more than 2 layers.
Note that the type checking for additional layers is carried out by the Thinc Mypy plugin.
nONr   nITz>>c              3   8   #    U  H  oR                   v   M     g 7fr   )name).0r   s     r   	<genexpr>chain.<locals>.<genexpr>'   s     5****s   )initdimsr   )extendhas_dimget_dimr   joinforwardr'   )r   r   r   
all_layersr(   models         r   r   r      s     *0(8Jf&*D\D!}T"d*]**40T
!}T"*T
"~d#t+^++D1T
$)		5*55%E Lr   r/   Xis_trainc                    ^ / mU R                    H  nU" XS9u  pETR                  U5        UnM      S[        S[        4U4S jjnWU4$ )zZApply the layers of `model` in sequence, feeding the output from one
layer into the next.
)r1   dYr   c                 @   > [        T5       H  nU" U 5      nUn M     W$ r   )reversed)r3   callbackdX	callbackss      r   backpropforward.<locals>.backprop:   s'     +H"BB , 	r   )r   appendr   r   )r/   r0   r1   r   Yinc_layer_gradr9   r8   s          @r   r-   r-   0   sW     I!!7( 
T c  h;r   Nr<   c                     Uc  Uc  U R                    H  nUR                  5         M     U R                   S   R                  S5      (       a.  U R                  SU R                   S   R	                  S5      5        U R                   S   R                  S5      (       a.  U R                  SU R                   S   R	                  S5      5        UnU R                    HJ  nUR                  S5      c  UR                  XBS9  OUR                  US9  Uc  M9  UR                  U5      nML     U R                   S   R                  S5      (       a.  U R                  SU R                   S   R	                  S5      5        U R                  S5      c   [        U5      nU R                  SU5        g g ! [         aX    U R                   S   R                  S5      (       a2  U R                   S   R	                  S5      nU R                  SU5         g  g f = f)Nr   r    r!   r   )r0   r<   )r0   )r   
initializer*   set_dimr+   predictr   
ValueError)r/   r0   r<   r   
curr_inputr   s         r   r'   r'   C   s   
 	yQY\\E "<<?""4((MM$Q 7 7 =><<##D))MM$R 0 8 8 >? J==&z/z*!z2J  ||At$$dELLO33D9:}}T"	(:&BMM$# #  	(||B''--\\"%--d3dB' .	(s   F+ +AHH)NN)typingr   r   r   r   r   r   r	   r
   configr   r/   r   typesr   utilr   r   r   r   r   r   r   boolr-   r'    r   r   <module>rJ      s   L L L    envv 
5 U  #t)&+D#I&6AFsCx
3
?<5d#  t dHn@U * #(d#(}#( ~#( 
	#(r   