U
    ,-e                      @   s   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ eeZd	d
dddddZG dd deZG dd de
ZdS )z MobileViT model configuration    OrderedDict)Mapping)version   )PretrainedConfig)
OnnxConfig)loggingzEhttps://huggingface.co/apple/mobilevit-small/resolve/main/config.jsonzGhttps://huggingface.co/apple/mobilevit-x-small/resolve/main/config.jsonzHhttps://huggingface.co/apple/mobilevit-xx-small/resolve/main/config.jsonzOhttps://huggingface.co/apple/deeplabv3-mobilevit-small/resolve/main/config.jsonzQhttps://huggingface.co/apple/deeplabv3-mobilevit-x-small/resolve/main/config.jsonzRhttps://huggingface.co/apple/deeplabv3-mobilevit-xx-small/resolve/main/config.json)zapple/mobilevit-smallzapple/mobilevit-x-smallzapple/mobilevit-xx-smallzapple/deeplabv3-mobilevit-smallz!apple/deeplabv3-mobilevit-x-smallz"apple/deeplabv3-mobilevit-xx-smallc                       sj   e Zd ZdZdZddddddgd	d
dddddgdddddd
ddddddddddgddf fdd	Z  ZS )MobileViTConfiga  
    This is the configuration class to store the configuration of a [`MobileViTModel`]. It is used to instantiate a
    MobileViT 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 MobileViT
    [apple/mobilevit-small](https://huggingface.co/apple/mobilevit-small) architecture.

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

    Args:
        num_channels (`int`, *optional*, defaults to 3):
            The number of input channels.
        image_size (`int`, *optional*, defaults to 256):
            The size (resolution) of each image.
        patch_size (`int`, *optional*, defaults to 2):
            The size (resolution) of each patch.
        hidden_sizes (`List[int]`, *optional*, defaults to `[144, 192, 240]`):
            Dimensionality (hidden size) of the Transformer encoders at each stage.
        neck_hidden_sizes (`List[int]`, *optional*, defaults to `[16, 32, 64, 96, 128, 160, 640]`):
            The number of channels for the feature maps of the backbone.
        num_attention_heads (`int`, *optional*, defaults to 4):
            Number of attention heads for each attention layer in the Transformer encoder.
        mlp_ratio (`float`, *optional*, defaults to 2.0):
            The ratio of the number of channels in the output of the MLP to the number of channels in the input.
        expand_ratio (`float`, *optional*, defaults to 4.0):
            Expansion factor for the MobileNetv2 layers.
        hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
            The non-linear activation function (function or string) in the Transformer encoder and convolution layers.
        conv_kernel_size (`int`, *optional*, defaults to 3):
            The size of the convolutional kernel in the MobileViT layer.
        output_stride (`int`, `optional`, defaults to 32):
            The ratio of the spatial resolution of the output to the resolution of the input image.
        hidden_dropout_prob (`float`, *optional*, defaults to 0.1):
            The dropout probabilitiy for all fully connected layers in the Transformer encoder.
        attention_probs_dropout_prob (`float`, *optional*, defaults to 0.0):
            The dropout ratio for the attention probabilities.
        classifier_dropout_prob (`float`, *optional*, defaults to 0.1):
            The dropout ratio for attached classifiers.
        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-5):
            The epsilon used by the layer normalization layers.
        qkv_bias (`bool`, *optional*, defaults to `True`):
            Whether to add a bias to the queries, keys and values.
        aspp_out_channels (`int`, `optional`, defaults to 256):
            Number of output channels used in the ASPP layer for semantic segmentation.
        atrous_rates (`List[int]`, *optional*, defaults to `[6, 12, 18]`):
            Dilation (atrous) factors used in the ASPP layer for semantic segmentation.
        aspp_dropout_prob (`float`, *optional*, defaults to 0.1):
            The dropout ratio for the ASPP layer for semantic segmentation.
        semantic_loss_ignore_index (`int`, *optional*, defaults to 255):
            The index that is ignored by the loss function of the semantic segmentation model.

    Example:

    ```python
    >>> from transformers import MobileViTConfig, MobileViTModel

    >>> # Initializing a mobilevit-small style configuration
    >>> configuration = MobileViTConfig()

    >>> # Initializing a model from the mobilevit-small style configuration
    >>> model = MobileViTModel(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```Z	mobilevitr                         @   `         i     g       @g      @Zsilug?g        g{Gz?gh㈵>T            c                    s   t  jf | || _|| _|| _|| _|| _|| _|| _|| _	|	| _
|
| _|| _|| _|| _|| _|| _|| _|| _|| _|| _|| _|| _d S )N)super__init__num_channels
image_size
patch_sizehidden_sizesneck_hidden_sizesnum_attention_heads	mlp_ratioexpand_ratio
hidden_actconv_kernel_sizeoutput_stridehidden_dropout_probattention_probs_dropout_probclassifier_dropout_probinitializer_rangelayer_norm_epsqkv_biasaspp_out_channelsatrous_ratesaspp_dropout_probsemantic_loss_ignore_index)selfr   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   kwargs	__class__ v/var/www/html/Darija-Ai-Train/env/lib/python3.8/site-packages/transformers/models/mobilevit/configuration_mobilevit.pyr   t   s,    zMobileViTConfig.__init__)__name__
__module____qualname____doc__Z
model_typer   __classcell__r6   r6   r4   r7   r
   .   s0   Cr
   c                   @   sl   e Zd ZedZeeeee	ef f dddZ
eeeee	ef f dddZeedddZd	S )
MobileViTOnnxConfigz1.11)returnc                 C   s   t ddddddfgS )NZpixel_valuesbatchr   heightwidth)r      r   r   r   r2   r6   r6   r7   inputs   s    zMobileViTOnnxConfig.inputsc                 C   s<   | j dkrtdddifgS tdddifdddifgS d S )Nzimage-classificationZlogitsr   r?   Zlast_hidden_stateZpooler_output)taskr   rC   r6   r6   r7   outputs   s    
zMobileViTOnnxConfig.outputsc                 C   s   dS )Ng-C6?r6   rC   r6   r6   r7   atol_for_validation   s    z'MobileViTOnnxConfig.atol_for_validationN)r8   r9   r:   r   parseZtorch_onnx_minimum_versionpropertyr   strintrD   rF   floatrG   r6   r6   r6   r7   r=      s   
  r=   N)r;   collectionsr   typingr   	packagingr   Zconfiguration_utilsr   Zonnxr   utilsr	   Z
get_loggerr8   loggerZ'MOBILEVIT_PRETRAINED_CONFIG_ARCHIVE_MAPr
   r=   r6   r6   r6   r7   <module>   s    
z