o
    ei                     @   sh   d dl mZ ddlmZ ddlmZ ddlmZmZ er"ddl	m
Z
 eeZG dd	 d	eZd	gZd
S )    )TYPE_CHECKING   )PreTrainedConfig)logging   )CONFIG_MAPPING
AutoConfig)SuperPointConfigc                       sr   e Zd ZdZdZdeiZ										
ddddedee dB dee	 dB dedede
de
f f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.
        is_decoder (`bool`, *optional*, defaults to `False`):
            Whether to only use the decoder in an encoder-decoder architecture, otherwise it has no effect on
            decoder-only or encoder-only architectures.

    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
        ```
    	supergluekeypoint_detector_configN      d           {Gz?Fr	   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 std|| dkr%td|d ur+|ng d	| _|| _|| _|| _ || _|| _|| _t|t	rZ|
d
d|d
< t|d
  di |}|d u rctd  }|| _|| _d| _d| _t jdi |
 d S )Nselfcross	   c                 s   s    | ]}|d v V  qdS ))r   r   N ).0
layer_typer   r   s/home/ubuntu/transcripts/venv/lib/python3.10/site-packages/transformers/models/superglue/configuration_superglue.py	<genexpr>[   s    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
superpointFr   )r   all
ValueErrorr   r   r   r   r   
isinstancedictgetr   r   r   attention_probs_dropout_prob
is_decodersuper__init__)r   r   r   r   r   r   r   r   r   r,   kwargs	__class__r   r   r.   L   s2   

zSuperGlueConfig.__init__)	Nr   NNr   r   r   r   F)__name__
__module____qualname____doc__r$   r   sub_configsintliststrfloatr.   __classcell__r   r   r0   r   r
      s<    -

	r
   N)typingr   configuration_utilsr   utilsr   autor   r   r%   r	   
get_loggerr2   loggerr
   __all__r   r   r   r   <module>   s   

`