
    i                         d dl mZ ddlmZ ddlmZmZ  e       rd dlZ ed      e G d d	e                    Zd	gZ	y)
    )strict   )PreTrainedConfig)auto_docstringis_detectron2_availableNzmicrosoft/layoutxlm-base)
checkpointc                       e Zd ZU dZdZdZeed<   dZeed<   dZ	eed<   dZ
eed	<   d
Zeed<   dZeed<   dZeez  ed<   dZeez  ed<   dZeed<   dZeed<   dZeed<   dZeed<   dZedz  ed<   dZeed<   dZeed<   d Zeed!<   d"Zeed#<   d$Zeed%<   d&Zeed'<   d"Zeed(<   d)Zee   e ed*f   z  ed+<   dZ!eed,<   dZ"eed-<   d"Z#eed.<   d"Z$eed/<   d0Z%eed1<   dZ&e'dz  ed2<    fd3Z(e)d4        Z*d5 Z+ xZ,S )6LayoutXLMConfiga
  
    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.
    convert_sync_batchnorm (`bool`, *optional*, defaults to `True`):
        Whether or not to convert batch normalization layers to synchronized batch normalization layers.
    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/layoutxlm/detectron2_config.py)
        for details regarding default values.

    Example:

    ```python
    >>> from transformers import LayoutXLMConfig, LayoutXLMModel

    >>> # Initializing a LayoutXLM microsoft/layoutxlm-base style configuration
    >>> configuration = LayoutXLMConfig()

    >>> # Initializing a model (with random weights) from the microsoft/layoutxlm-base style configuration
    >>> model = LayoutXLMModel(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```	layoutxlmi:w  
vocab_sizei   hidden_size   num_hidden_layersnum_attention_headsi   intermediate_sizegelu
hidden_actg?hidden_dropout_probattention_probs_dropout_prob   max_position_embeddings   type_vocab_sizeg{Gz?initializer_rangeg-q=layer_norm_epsr   Npad_token_idi   max_2d_position_embeddings   max_rel_pos    rel_pos_binsTfast_qkv   max_rel_2d_pos@   rel_2d_pos_binsconvert_sync_batchnorm)   r(   r#   .image_feature_pool_shapecoordinate_size
shape_sizehas_relative_attention_biashas_spatial_attention_biasFhas_visual_segment_embeddingdetectron2_config_argsc                     t        |   di | | j                  | j                  | _        y | j                         | _        y )N )super__post_init__r/   get_default_detectron2_config)selfkwargs	__class__s     /var/www/vps2.regionflexible.com/Desarrollo/venv/lib/python3.12/site-packages/transformers/models/layoutxlm/configuration_layoutxlm.pyr3   zLayoutXLMConfig.__post_init__r   sJ    '' **6 '' 	# 335 	#    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@   rA   rB   rC   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_1X1r1   )clss    r8   r4   z-LayoutXLMConfig.get_default_detectron2_configz   s+   
T
7
 "#>
 $%E	

 +bTB4#u,M
 $%C
 +D
 *4
 ,T
 '
 #$6
 *1
 *+C
 &';
 (
  3B!
" '(B#
$ -.56#&%'D2$use#D,;+<*J(*-.+05
 	
r9   c                     t         j                  j                         }| j                  j	                         D ]>  \  }}|j                  d      }|}|d d D ]  }t        ||      } t        ||d   |       @ |S )N.)
detectron2configget_cfgr/   itemssplitgetattrsetattr)r5   detectron2_configkv
attributesto_set	attributes          r8   get_detectron2_configz%LayoutXLMConfig.get_detectron2_config   s    &--557//557 	/DAqJ&F'_ 4	 34FJrNA.	/ ! r9   )-__name__
__module____qualname____doc__
model_typer   int__annotations__r   r   r   r   r   strr   floatr   r   r   r   r   r   r   r   r!   r"   boolr$   r&   r'   r)   listtupler*   r+   r,   r-   r.   r/   dictr3   classmethodr4   r^   __classcell__)r7   s   @r8   r
   r
   !   sk   .` JJKs!!!s!J'**03 %#+3#&S&OS#u#!NE! L#* &**KL#HdNCOS#'D'<Gd3i%S/9GOSJ(,,'++). $.*.D4K.
 
 
<	!r9   r
   )
huggingface_hub.dataclassesr   configuration_utilsr   utilsr   r   rQ   r
   __all__r1   r9   r8   <module>rr      sS   , / 3 <  56!& !  7!D 
r9   