
    i                     
   d dl mZmZmZ d dlmZmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZ d dlmZmZ ddlmZ ddlmZ dd	eeef   fd
Zded	eeef   fdZdeee   ee   f   deeef   deeef   d	eeee   ef   ef   fdZy)    )ListTuplecast)LinearLogisticMaxoutModelchainconcatenateglorot_uniform_initlist2raggedreduce_firstreduce_last
reduce_maxreduce_meanwith_getitem)Floats2dRagged   )Doc   )extract_spansNreturnc                 J    t        t        | |t              t                     S )zrAn output layer for multi-label classification. It uses a linear layer
    followed by a logistic activation.
    )nOnIinit_W)r
   r   r   r   )r   r   s     h/var/www/vps2.regionflexible.com/Desarrollo/venv/lib/python3.12/site-packages/spacy/ml/models/spancat.pybuild_linear_logisticr      s     2"-@A8:NN    hidden_sizec           
          t        t        t        t        t        t
        f   t                     t        t        t        t
        f   t                     t               t                     t        | dd            S )zReduce sequences by concatenating their mean and max pooled vectors,
    and then combine the concatenated vectors with a hidden layer.
    Tg        )r   	normalizedropout)r
   r   r   r	   r   r   r   r   r   r   r   )r!   s    r   build_mean_max_reducerr%      s]     vx'(+-8vx'(,.9ML		
 	+s; r    tok2vecreducerscorerc                    t        t        t        t        t        t
           t        f   t        t        t        f   f   t        dt        | t        t        t        t           t        f   t                                       t               ||      }|j                  d|        |j                  d|       |j                  d|       |S )a  Build a span categorizer model, given a token-to-vector model, a
    reducer model to map the sequence of vectors for each span down to a single
    vector, and a scorer model to map the vectors to probabilities.

    tok2vec (Model[List[Doc], List[Floats2d]]): The tok2vec model.
    reducer (Model[Ragged, Floats2d]): The reducer model.
    scorer (Model[Floats2d, Floats2d]): The scorer model.
    r   r&   r'   r(   )r
   r   r	   r   r   r   r   r   r   r   r   set_ref)r&   r'   r(   models       r   build_spancat_modelr,   .   s     %S	6)*E&&.,AAB5$uT(^V-C'Dkm"TU	
 	
E 
MM)W%	MM)W%	MM(F#Lr    )NN)typingr   r   r   	thinc.apir   r   r   r	   r
   r   r   r   r   r   r   r   r   thinc.typesr   r   tokensr   r   r   intr%   r,    r    r   <module>r3      s    $ $    )  )OuXx5G/H O fh6F0G 49d8n,-68#$ (H$% 5cF"#X-.	r    