o
    Zh                     @   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G d	d
 d
eZG dd de
Zd
dgZdS )zMobileViTV2 model configuration    OrderedDict)Mapping)version   )PretrainedConfig)
OnnxConfig)loggingc                       sZ   e Zd ZdZdZdddddddd	d
ddg dd	dg dg dddddf fdd	Z  ZS )MobileViTV2Configa  
    This is the configuration class to store the configuration of a [`MobileViTV2Model`]. It is used to instantiate a
    MobileViTV2 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 MobileViTV2
    [apple/mobilevitv2-1.0](https://huggingface.co/apple/mobilevitv2-1.0) 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.
        expand_ratio (`float`, *optional*, defaults to 2.0):
            Expansion factor for the MobileNetv2 layers.
        hidden_act (`str` or `function`, *optional*, defaults to `"swish"`):
            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 MobileViTV2 layer.
        output_stride (`int`, *optional*, defaults to 32):
            The ratio of the spatial resolution of the output to the resolution of the input image.
        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-05):
            The epsilon used by the layer normalization layers.
        aspp_out_channels (`int`, *optional*, defaults to 512):
            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.
        n_attn_blocks (`List[int]`, *optional*, defaults to `[2, 4, 3]`):
            The number of attention blocks in each MobileViTV2Layer
        base_attn_unit_dims (`List[int]`, *optional*, defaults to `[128, 192, 256]`):
            The base multiplier for dimensions of attention blocks in each MobileViTV2Layer
        width_multiplier (`float`, *optional*, defaults to 1.0):
            The width multiplier for MobileViTV2.
        ffn_multiplier (`int`, *optional*, defaults to 2):
            The FFN multiplier for MobileViTV2.
        attn_dropout (`float`, *optional*, defaults to 0.0):
            The dropout in the attention layer.
        ffn_dropout (`float`, *optional*, defaults to 0.0):
            The dropout between FFN layers.

    Example:

    ```python
    >>> from transformers import MobileViTV2Config, MobileViTV2Model

    >>> # Initializing a mobilevitv2-small style configuration
    >>> configuration = MobileViTV2Config()

    >>> # Initializing a model from the mobilevitv2-small style configuration
    >>> model = MobileViTV2Model(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```Zmobilevitv2r         g       @Zswish    g?g{Gz?gh㈵>i   )            )r      r   )      r   g      ?g        c                    s   t  jdi | || _|| _|| _|| _|| _|| _|| _|	| _	|
| _
|| _|| _|| _|| _|| _|| _|| _|| _|| _|| _|| _d S )N )super__init__num_channels
image_size
patch_sizeexpand_ratio
hidden_actconv_kernel_sizeoutput_strideinitializer_rangelayer_norm_epsn_attn_blocksbase_attn_unit_dimswidth_multiplierffn_multiplierffn_dropoutattn_dropoutclassifier_dropout_prob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&   r%   kwargs	__class__r   h/var/www/auris/lib/python3.10/site-packages/transformers/models/mobilevitv2/configuration_mobilevitv2.pyr   c   s*   
zMobileViTV2Config.__init__)__name__
__module____qualname____doc__Z
model_typer   __classcell__r   r   r.   r0   r
      s0    Br
   c                   @   sl   e Zd ZedZedeeee	ef f fddZ
edeeee	ef f fddZedefddZd	S )
MobileViTV2OnnxConfigz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   r,   r   r   r0   inputs   s   zMobileViTV2OnnxConfig.inputsc                 C   s8   | 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 )Nzimage-classificationZlogitsr   r8   Zlast_hidden_stateZpooler_output)taskr   r<   r   r   r0   outputs   s   
zMobileViTV2OnnxConfig.outputsc                 C   s   dS )Ng-C6?r   r<   r   r   r0   atol_for_validation   s   z)MobileViTV2OnnxConfig.atol_for_validationN)r1   r2   r3   r   parseZtorch_onnx_minimum_versionpropertyr   strintr=   r?   floatr@   r   r   r   r0   r6      s    
  r6   N)r4   collectionsr   typingr   	packagingr   Zconfiguration_utilsr   Zonnxr   utilsr	   Z
get_loggerr1   loggerr
   r6   __all__r   r   r   r0   <module>   s   
w