
    i4                     x    d Z ddlmZ ddlmZ ddlmZ ddlmZ  ed      e G d	 d
ee                    Z	d
gZ
y)zHiera model configuration    )strict   )BackboneConfigMixin)PreTrainedConfig)auto_docstringzfacebook/hiera-base-224)
checkpointc                       e Zd ZU dZdZddiZdZeed<   dZ	e
e   eedf   z  ed	<   d
Ze
e   eedf   z  ed<   dZe
e   eedf   z  ed<   dZe
e   eedf   z  ed<   dZeed<   dZe
e   eedf   z  ed<   dZe
e   eedf   z  ed<   dZeez  ed<   dZeed<   dZe
e   eedf   z  ed<   dZe
e   eedf   z  ed<   dZe
e   eedf   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ed*<   d+Z ed+z  ed,<   d+Z!ed+z  ed-<   d+Z"ed+z  ed.<   d/Z#ed+z  ed0<   d1Z$eed2<   d+Z%e
e   d+z  ed3<   d+Z&e
e   d+z  ed4<    fd5Z'd6 Z( xZ)S )7HieraConfigai  
    patch_stride (`list(int)`, *optional*, defaults to `[4, 4]`):
        The stride of the patch.
    patch_padding (`list(int)`, *optional*, defaults to `[3, 3]`):
        The padding of the patch.
    num_heads (`list(int)`, *optional*, defaults to `[1, 2, 4, 8]`):
        Number of attention heads in each layer of the Transformer encoder.
    embed_dim_multiplier (`float`, *optional*, defaults to 2.0):
        The multiplier to the dimensionality of patch embedding in each layer of the Transformer encoder.
    num_query_pool (`int`, *optional*, defaults to 3):
        The number of query pool stages.
    query_stride (`list(int)`, *optional*, defaults to `[2, 2]`):
        The stride of the query pool.
    masked_unit_size (`list(int)`, *optional*, defaults to `[8, 8]`):
        The size of the masked unit.
    masked_unit_attention (`list(bool)`, *optional*, defaults to `[True, True, False, False]`):
        Whether to use masked unit attention in each layer of the Transformer encoder.
    layer_norm_init (`float`, *optional*, defaults to 1.0):
        The initial weight value for layer normalization layers.
    decoder_depth (`int`, *optional*):
        Depth of the decoder for MAE pretraining.
    normalize_pixel_loss (`bool`, *optional*, defaults to `True`):
        Whether to normalize the pixel loss by the number of pixels.
    mask_ratio (`float`, *optional*, defaults to 0.6):
        The ratio of masked tokens in the input.

    Example:

    ```python
    >>> from transformers import HieraConfig, HieraModel

    >>> # Initializing a Hiera hiera-base-patch16-224 style configuration
    >>> configuration = HieraConfig()

    >>> # Initializing a model (with random weights) from the hiera-base-patch16-224 style configuration
    >>> model = HieraModel(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```hieranum_hidden_layers
num_layers`   	embed_dim)   r   .
image_size)   r   
patch_size)   r   patch_stride)r   r   patch_paddingg      @	mlp_ratio)   r      r   depths)   r   r      	num_headsg       @embed_dim_multiplierr   num_query_pool)r   r   query_stride)r   r   masked_unit_size)TTFFmasked_unit_attentiong        drop_path_ratenum_channelsgelu
hidden_actg{Gz?initializer_rangeg      ?layer_norm_initgư>layer_norm_epsNdecoder_hidden_sizedecoder_depthdecoder_num_headsTnormalize_pixel_lossg333333?
mask_ratio_out_features_out_indicesc                    t        | j                  | j                  t        | j                        dz
  z  z        | _        dgt        dt        | j                        dz         D cg c]  }d| 	 c}z   | _        | j                  |j                  dd       |j                  dd              t        | ,  di | y c c}w )Nr   stemstageout_indicesout_features)r4   r5    )intr   r   lenr   hidden_sizerangestage_names"set_output_features_output_indicespopsuper__post_init__)selfkwargsidx	__class__s      ~/var/www/vps2.regionflexible.com/Desarrollo/venv/lib/python3.12/site-packages/transformers/models/hiera/configuration_hiera.pyr?   zHieraConfig.__post_init__b   s     t~~0I0IcRVR]R]N^abNb0ccd"8aT[[IY\]I]@^&_se}&__//

=$7fjjQ_aeFf 	0 	
 	''	 '`s   (Cc           
         | j                   d   | j                  d   t        | j                        dz
  z  z  dk7  rEt	        d| j                   d    d| j                  d    dt        | j                        dz
   d      | j
                  t        | j                        k\  r/t	        d| j
                   dt        | j                         d      y	)
zOPart of `@strict`-powered validation. Validates the architecture of the config.r   r   zmasked_unit_size[0] (z() must be divisible by query_stride[0] (z/) raised to the power of the number of layers ()znum_query_pool (z*) must be less than the number of layers (N)r!   r    r8   r   
ValueErrorr   )r@   s    rD   validate_architecturez!HieraConfig.validate_architecturel   s      #d&7&7&:s4;;?ORS?S&TTXYY'(=(=a(@'AAijnj{j{|}j~i @@@CDKK@PST@T?UUVX 
 #dkk"22"4#6#6"77abefjfqfqbrasstu  3    )*__name__
__module____qualname____doc__
model_typeattribute_mapr   r7   __annotations__r   listtupler   r   r   r   floatr   r   r   r   r    r!   r"   boolr#   r$   r&   strr'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r?   rH   __classcell__)rC   s   @rD   r
   r
      s   'R J(,7MIs.8JS	E#s(O+8.4JS	E#s(O+406L$s)eCHo-617M49uS#X.7Iu*7FDIc3h'7-9ItCy5c?*9(+%#++NC06L$s)eCHo-64:d3i%S/1:;U4:dCi(88U"%NECK%L#J#u# OU  NE &*t* $M3:$$(sTz((,$+,J&*M49t#*%)L$s)d")(rI   r
   N)rM   huggingface_hub.dataclassesr   backbone_utilsr   configuration_utilsr   utilsr   r
   __all__r6   rI   rD   <module>r\      sP      . 1 3 # 45^%'7 ^  6^B /rI   