
    i              
          d dl 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 ddlmZ eZeZ ej                   d      dd	eed
f   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	 ddeeef   dee   dee   ddfdZy)    )CallableOptionalTuplecast   )registry)Model)Floats1dFloats2d)	get_widthzMultiSoftmax.v1NnOs.nIreturnc           
      V    t        dt        t        t        |       |dd| iddd      S )aB  Neural network layer that predicts several multi-class attributes at once.
    For instance, we might predict one class with 6 variables, and another with 5.
    We predict the 11 neurons required for this, and then softmax them such
    that columns 0-6 make a probability distribution and columns 6-11 make another.
    multisoftmax)nOr   r   N)Wb)initdimsattrsparams)r	   forwardr   sum)r   r   s     j/var/www/vps2.regionflexible.com/Desarrollo/venv/lib/python3.12/site-packages/thinc/layers/multisoftmax.pyMultiSoftmaxr      s5     HB'cl%     modelXis_trainc                    	  j                   d   }t        t         j                  d            	t        t         j                  d            }dt
        dt        f	 fd} j                  j                  	d      }||z  }d	}|D ]0  } j                  j                  |d d |||z   f   d
       ||z  }2 ||fS )Nr   r   r   dYr   c                     j                  dj                  j                  | d             j                  d| j                  d             j                  j                  |       S )Nr   T)trans1r   r   )axis)inc_gradopsgemmr   )r"   r   r   r   s    r   backpropzforward.<locals>.backprop"   sQ    sEIINN2qN>?sBFFFN+yy~~b!$$r   T)trans2r   )inplace)
r   r   r   	get_paramr
   OutTInTr'   r(   softmax)
r   r   r    r   r   r)   Yiout_sizer   s
   ``       @r   r   r      s    
++e
CXus+,AXus+,A%T %c %
 			q!D)AFA	A 		!Aq1x<//0$?	X h;r   r0   c                 0   || j                  dt        |             | j                  d      }| j                  d      }| j                  d| j                  j                  ||             | j                  d| j                  j                  |             y )Nr   r   r   r   )set_dimr   get_dim	set_paramr'   alloc2falloc1f)r   r   r0   r   r   s        r   r   r   0   ss     	}dIaL)	t	B	t	B	OOC**2r23	OOC**2./r   )N)NN)typingr   r   r   r   configr   r   r	   typesr
   r   utilr   r.   r-   layersintr   boolr   r    r   r   <module>rA      s    2 2   &  "#eCHo 8C= E#t)DT  $ 5d#  t dHn@U ( KO0d0 (09A$0	0r   