a
    ¾Àha  ã                   @   sh   d dl mZmZ ddlmZ ddlmZ ddlmZ erDddl	m
Z
 e e¡ZG dd	„ d	eƒZd	gZd
S )é    )ÚTYPE_CHECKINGÚOptionalé   )ÚPretrainedConfig)Úloggingé   )ÚCONFIG_MAPPING)ÚSuperPointConfigc                
       sV   e Zd ZdZdZdd	eeee  eee  eee	e	d
œ‡ fdd„Z
edd„ ƒZ‡  ZS )ÚSuperGlueConfiga	  
    This is the configuration class to store the configuration of a [`SuperGlueModel`]. It is used to instantiate a
    SuperGlue 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 SuperGlue
    [magic-leap-community/superglue_indoor](https://huggingface.co/magic-leap-community/superglue_indoor) architecture.

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

    Args:
        keypoint_detector_config (`Union[AutoConfig, dict]`,  *optional*, defaults to `SuperPointConfig`):
            The config object or dictionary of the keypoint detector.
        hidden_size (`int`, *optional*, defaults to 256):
            The dimension of the descriptors.
        keypoint_encoder_sizes (`list[int]`, *optional*, defaults to `[32, 64, 128, 256]`):
            The sizes of the keypoint encoder layers.
        gnn_layers_types (`list[str]`, *optional*, defaults to `['self', 'cross', 'self', 'cross', 'self', 'cross', 'self', 'cross', 'self', 'cross', 'self', 'cross', 'self', 'cross', 'self', 'cross', 'self', 'cross']`):
            The types of the GNN layers. Must be either 'self' or 'cross'.
        num_attention_heads (`int`, *optional*, defaults to 4):
            The number of heads in the GNN layers.
        sinkhorn_iterations (`int`, *optional*, defaults to 100):
            The number of Sinkhorn iterations.
        matching_threshold (`float`, *optional*, defaults to 0.0):
            The matching threshold.
        initializer_range (`float`, *optional*, defaults to 0.02):
            The standard deviation of the truncated_normal_initializer for initializing all weight matrices.

    Examples:
        ```python
        >>> from transformers import SuperGlueConfig, SuperGlueModel

        >>> # Initializing a SuperGlue superglue style configuration
        >>> configuration = SuperGlueConfig()

        >>> # Initializing a model from the superglue style configuration
        >>> model = SuperGlueModel(configuration)

        >>> # Accessing the model configuration
        >>> configuration = model.config
        ```
    Z	superglueNé   é   éd   ç        ç{®Gáz”?r	   )Úkeypoint_detector_configÚhidden_sizeÚkeypoint_encoder_sizesÚgnn_layers_typesÚnum_attention_headsÚsinkhorn_iterationsÚmatching_thresholdÚinitializer_rangec	           
         sô   |d ur|n
ddgd | _ tdd„ | j D ƒƒs6tdƒ‚|| dkrJtdƒ‚|d urV|ng d	¢| _|| _|| _|| _ || _|| _|| _t|t	ƒr´| 
d
d¡|d
< t|d
  f i |¤Ž}|d u rÆtd ƒ }|| _|| _d| _d| _tƒ jf i |	¤Ž d S )NÚselfÚcrossé	   c                 s   s   | ]}|d v V  qdS ))r   r   N© )Ú.0Z
layer_typer   r   úq/var/www/html/assistant/venv/lib/python3.9/site-packages/transformers/models/superglue/configuration_superglue.pyÚ	<genexpr>V   ó    z+SuperGlueConfig.__init__.<locals>.<genexpr>z5All gnn_layers_types must be either 'self' or 'cross'r   z8hidden_size % num_attention_heads is different from zero)é    é@   é€   r   Ú
model_typeÚ
superpointF)r   ÚallÚ
ValueErrorr   r   r   r   r   Ú
isinstanceÚdictÚgetr   r   r   Zattention_probs_dropout_probZ
is_decoderÚsuperÚ__init__)
r   r   r   r   r   r   r   r   r   Úkwargs©Ú	__class__r   r   r+   H   s2    ÿ
ÿ
zSuperGlueConfig.__init__c                 C   s   dt | jƒiS )Nr   )Útyper   )r   r   r   r   Úsub_configsu   s    zSuperGlueConfig.sub_configs)Nr   NNr   r   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r#   Úintr   ÚlistÚstrÚfloatr+   Úpropertyr0   Ú__classcell__r   r   r-   r   r
      s,   *        ÷

÷-r
   N)Útypingr   r   Zconfiguration_utilsr   Úutilsr   Úautor   r$   r	   Z
get_loggerr1   Úloggerr
   Ú__all__r   r   r   r   Ú<module>   s   
_