o
    i                     @   s  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lmZ dd
eeef fddZded
eeef fd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dZd	S )    )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)registry   )extract_spansNreturnc                 C   s   t t| |td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    r   K/home/ubuntu/.local/lib/python3.10/site-packages/spacy/ml/models/spancat.pybuild_linear_logistic   s   r   hidden_sizec                 C   sB   t tttttf t ttttf t t t	 t
| d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    r   r   r   build_mean_max_reducer    s   r#   tok2vecreducerscorerc                 C   sz   t ttttt tf tttf f tdt | tttt tf t	 t
 ||}|d|  |d| |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&   modelr   r   r   build_spancat_model/   s   r)   )NN)typingr   r   r   	thinc.apir   r   r   r   r	   r
   r   r   r   r   r   r   r   thinc.typesr   r   tokensr   utilr   r   r   intr#   r)   r   r   r   r   <module>   s"    <

