Ë
    T^(h¢*  ã                   óz   — d Z ddlmZ ddlmZmZ  ej                  e«      Z e«       rddl	Z	 G d„ de«      Z
dgZy)zLayoutLMv2 model configurationé   )ÚPretrainedConfig)Úis_detectron2_availableÚloggingé    Nc                   óx   ‡ — e Zd ZdZdZddddddddd	d
ddddddddddg d¢ddddddfˆ fd„	Zed„ «       Zd„ Zˆ xZ	S )ÚLayoutLMv2Configa^  
    This is the configuration class to store the configuration of a [`LayoutLMv2Model`]. It is used to instantiate an
    LayoutLMv2 model according to the specified arguments, defining the model architecture. Instantiating a
    configuration with the defaults will yield a similar configuration to that of the LayoutLMv2
    [microsoft/layoutlmv2-base-uncased](https://huggingface.co/microsoft/layoutlmv2-base-uncased) architecture.

    Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
    documentation from [`PretrainedConfig`] for more information.

    Args:
        vocab_size (`int`, *optional*, defaults to 30522):
            Vocabulary size of the LayoutLMv2 model. Defines the number of different tokens that can be represented by
            the `inputs_ids` passed when calling [`LayoutLMv2Model`] or [`TFLayoutLMv2Model`].
        hidden_size (`int`, *optional*, defaults to 768):
            Dimension of the encoder layers and the pooler layer.
        num_hidden_layers (`int`, *optional*, defaults to 12):
            Number of hidden layers in the Transformer encoder.
        num_attention_heads (`int`, *optional*, defaults to 12):
            Number of attention heads for each attention layer in the Transformer encoder.
        intermediate_size (`int`, *optional*, defaults to 3072):
            Dimension of the "intermediate" (i.e., feed-forward) layer in the Transformer encoder.
        hidden_act (`str` or `function`, *optional*, defaults to `"gelu"`):
            The non-linear activation function (function or string) in the encoder and pooler. If string, `"gelu"`,
            `"relu"`, `"selu"` and `"gelu_new"` are supported.
        hidden_dropout_prob (`float`, *optional*, defaults to 0.1):
            The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.
        attention_probs_dropout_prob (`float`, *optional*, defaults to 0.1):
            The dropout ratio for the attention probabilities.
        max_position_embeddings (`int`, *optional*, defaults to 512):
            The maximum sequence length that this model might ever be used with. Typically set this to something large
            just in case (e.g., 512 or 1024 or 2048).
        type_vocab_size (`int`, *optional*, defaults to 2):
            The vocabulary size of the `token_type_ids` passed when calling [`LayoutLMv2Model`] or
            [`TFLayoutLMv2Model`].
        initializer_range (`float`, *optional*, defaults to 0.02):
            The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
        layer_norm_eps (`float`, *optional*, defaults to 1e-12):
            The epsilon used by the layer normalization layers.
        max_2d_position_embeddings (`int`, *optional*, defaults to 1024):
            The maximum value that the 2D position embedding might ever be used with. Typically set this to something
            large just in case (e.g., 1024).
        max_rel_pos (`int`, *optional*, defaults to 128):
            The maximum number of relative positions to be used in the self-attention mechanism.
        rel_pos_bins (`int`, *optional*, defaults to 32):
            The number of relative position bins to be used in the self-attention mechanism.
        fast_qkv (`bool`, *optional*, defaults to `True`):
            Whether or not to use a single matrix for the queries, keys, values in the self-attention layers.
        max_rel_2d_pos (`int`, *optional*, defaults to 256):
            The maximum number of relative 2D positions in the self-attention mechanism.
        rel_2d_pos_bins (`int`, *optional*, defaults to 64):
            The number of 2D relative position bins in the self-attention mechanism.
        image_feature_pool_shape (`List[int]`, *optional*, defaults to [7, 7, 256]):
            The shape of the average-pooled feature map.
        coordinate_size (`int`, *optional*, defaults to 128):
            Dimension of the coordinate embeddings.
        shape_size (`int`, *optional*, defaults to 128):
            Dimension of the width and height embeddings.
        has_relative_attention_bias (`bool`, *optional*, defaults to `True`):
            Whether or not to use a relative attention bias in the self-attention mechanism.
        has_spatial_attention_bias (`bool`, *optional*, defaults to `True`):
            Whether or not to use a spatial attention bias in the self-attention mechanism.
        has_visual_segment_embedding (`bool`, *optional*, defaults to `False`):
            Whether or not to add visual segment embeddings.
        detectron2_config_args (`dict`, *optional*):
            Dictionary containing the configuration arguments of the Detectron2 visual backbone. Refer to [this
            file](https://github.com/microsoft/unilm/blob/master/layoutlmft/layoutlmft/models/layoutlmv2/detectron2_config.py)
            for details regarding default values.

    Example:

    ```python
    >>> from transformers import LayoutLMv2Config, LayoutLMv2Model

    >>> # Initializing a LayoutLMv2 microsoft/layoutlmv2-base-uncased style configuration
    >>> configuration = LayoutLMv2Config()

    >>> # Initializing a model (with random weights) from the microsoft/layoutlmv2-base-uncased style configuration
    >>> model = LayoutLMv2Model(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```Ú
layoutlmv2i:w  i   é   i   Úgelugš™™™™™¹?é   é   g{®Gáz”?gê-�™—q=r   i   é€   é    Té   é@   )é   r   r   FNc                 ó4  •— t        ‰| �  d|||||||||	|
|||dœ|¤Ž || _        || _        || _        || _        || _        || _        || _        || _	        || _
        || _        || _        || _        || _        |�|| _        y | j                  «       | _        y )N)Ú
vocab_sizeÚhidden_sizeÚnum_hidden_layersÚnum_attention_headsÚintermediate_sizeÚ
hidden_actÚhidden_dropout_probÚattention_probs_dropout_probÚmax_position_embeddingsÚtype_vocab_sizeÚinitializer_rangeÚlayer_norm_epsÚpad_token_id© )ÚsuperÚ__init__Úmax_2d_position_embeddingsÚmax_rel_posÚrel_pos_binsÚfast_qkvÚmax_rel_2d_posÚrel_2d_pos_binsÚconvert_sync_batchnormÚimage_feature_pool_shapeÚcoordinate_sizeÚ
shape_sizeÚhas_relative_attention_biasÚhas_spatial_attention_biasÚhas_visual_segment_embeddingÚget_default_detectron2_configÚdetectron2_config_args)Úselfr   r   r   r   r   r   r   r   r   r   r   r   r    r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r2   ÚkwargsÚ	__class__s                                €úu/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/layoutlmv2/configuration_layoutlmv2.pyr#   zLayoutLMv2Config.__init__s   sÖ   ø€ ô> 	‰Ñð 	
Ø!Ø#Ø/Ø 3Ø/Ø!Ø 3Ø)EØ$;Ø+Ø/Ø)Ø%ñ	
ð ò	
ð  +EˆÔ'Ø&ˆÔØ(ˆÔØ ˆŒØ,ˆÔØ.ˆÔØ&<ˆÔ#Ø(@ˆÔ%Ø.ˆÔØ$ˆŒØ+FˆÔ(Ø*DˆÔ'Ø,HˆÔ)à&<Ð&HÐ"ð 	Õ#ØNR×NpÑNpÓNrð 	Õ#ó    c                 óÆ   — i dd“dg d¢“dd“dg d¢“d	d
gdgdgdgdgg“dg d¢“dd“dd“dd“dd“dd“dd“dg d¢“dd“dd “d!d"“d#d$“d%d&d'd
gdgdgdgdggg d(¢gg d¢d
d)d*d+œ	¥S ),NzMODEL.MASK_ONTzMODEL.PIXEL_STD)g     °L@g�Âõ(\�L@gÃõ(\�2M@zMODEL.BACKBONE.NAMEÚbuild_resnet_fpn_backbonezMODEL.FPN.IN_FEATURES)Úres2Úres3Úres4Úres5zMODEL.ANCHOR_GENERATOR.SIZESr   r   r   r   r   zMODEL.RPN.IN_FEATURES)Úp2Úp3Úp4Úp5Úp6zMODEL.RPN.PRE_NMS_TOPK_TRAINiÐ  zMODEL.RPN.PRE_NMS_TOPK_TESTiè  zMODEL.RPN.POST_NMS_TOPK_TRAINzMODEL.POST_NMS_TOPK_TESTzMODEL.ROI_HEADS.NAMEÚStandardROIHeadszMODEL.ROI_HEADS.NUM_CLASSESé   zMODEL.ROI_HEADS.IN_FEATURES)r>   r?   r@   rA   zMODEL.ROI_BOX_HEAD.NAMEÚFastRCNNConvFCHeadzMODEL.ROI_BOX_HEAD.NUM_FCr   z$MODEL.ROI_BOX_HEAD.POOLER_RESOLUTIONé   zMODEL.ROI_MASK_HEAD.NAMEÚMaskRCNNConvUpsampleHeadé   r   ée   )g      à?g      ð?g       @é   F)	zMODEL.ROI_MASK_HEAD.NUM_CONVz%MODEL.ROI_MASK_HEAD.POOLER_RESOLUTIONzMODEL.RESNETS.DEPTHzMODEL.RESNETS.SIZESzMODEL.RESNETS.ASPECT_RATIOSzMODEL.RESNETS.OUT_FEATURESzMODEL.RESNETS.NUM_GROUPSzMODEL.RESNETS.WIDTH_PER_GROUPzMODEL.RESNETS.STRIDE_IN_1X1r!   )Úclss    r6   r1   z.LayoutLMv2Config.get_default_detectron2_config³   s+  € ð
Ø˜Tð
àÒ7ð
ð "Ð#>ð
ð $Ò%Eð	
ð
 +¨b¨T°B°4¸#¸ÀÀÈÀuÐ,Mð
ð $Ò%Cð
ð +¨Dð
ð *¨4ð
ð ,¨Tð
ð '¨ð
ð #Ð$6ð
ð *¨1ð
ð *Ò+Cð
ð &Ð';ð
ð (¨ð
ð  3°Bð!
ð" 'Ð(Bð#
ð$ -.Ø56Ø#&Ø%' D¨2¨$°°¸°u¸s¸eÐ#DÚ,;Ð+<Ú*JØ(*Ø-.Ø+0ò5
ð 	
r7   c                 óø   — t         j                  j                  «       }| j                  j	                  «       D ]>  \  }}|j                  d«      }|}|d d D ]  }t        ||«      }Œ t        ||d   |«       Œ@ |S )Nú.éÿÿÿÿ)Ú
detectron2ÚconfigÚget_cfgr2   ÚitemsÚsplitÚgetattrÚsetattr)r3   Údetectron2_configÚkÚvÚ
attributesÚto_setÚ	attributes          r6   Úget_detectron2_configz&LayoutLMv2Config.get_detectron2_configÒ   s„   € Ü&×-Ñ-×5Ñ5Ó7ÐØ×/Ñ/×5Ñ5Ó7ò 	/‰DˆAˆqØŸ™ ›ˆJØ&ˆFØ'¨¨˜_ò 4�	Ü  ¨Ó3‘ð4ä�F˜J r™N¨AÕ.ð	/ð !Ð r7   )
Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
model_typer#   Úclassmethodr1   r\   Ú__classcell__)r5   s   @r6   r   r      sƒ   ø„ ñQðf €Jð ØØØØØØØ%(Ø #ØØØØØ#'ØØØØØØ#Ú!,ØØØ$(Ø#'Ø%*Ø#õ9>
ð@ ñ
ó ð
ö<	!r7   r   )r`   Úconfiguration_utilsr   Úutilsr   r   Ú
get_loggerr]   ÚloggerrO   r   Ú__all__r!   r7   r6   ú<module>ri      sI   ðñ %å 3ß 5ð 
ˆ×	Ñ	˜HÓ	%€ñ ÔÛô~!Ð'ô ~!ðB Ð
�r7   