o
    Zh                     @   s   d Z ddlmZ ddlmZ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 EfficientNet model configuration    OrderedDict)ListMapping)version   )PretrainedConfig)
OnnxConfig)loggingc                +       s   e Zd ZdZdZdddddg dg d	g d
g g dg dg ddddddddddfdedededededee dee dee dee d ee d!ee d"ee d#ed$ed%ed&ed'ed(ed)ed*ed+ef* fd,d-Z	  Z
S ).EfficientNetConfiga#  
    This is the configuration class to store the configuration of a [`EfficientNetModel`]. It is used to instantiate an
    EfficientNet 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 EfficientNet
    [google/efficientnet-b7](https://huggingface.co/google/efficientnet-b7) 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 600):
            The input image size.
        width_coefficient (`float`, *optional*, defaults to 2.0):
            Scaling coefficient for network width at each stage.
        depth_coefficient (`float`, *optional*, defaults to 3.1):
            Scaling coefficient for network depth at each stage.
        depth_divisor `int`, *optional*, defaults to 8):
            A unit of network width.
        kernel_sizes (`List[int]`, *optional*, defaults to `[3, 3, 5, 3, 5, 5, 3]`):
            List of kernel sizes to be used in each block.
        in_channels (`List[int]`, *optional*, defaults to `[32, 16, 24, 40, 80, 112, 192]`):
            List of input channel sizes to be used in each block for convolutional layers.
        out_channels (`List[int]`, *optional*, defaults to `[16, 24, 40, 80, 112, 192, 320]`):
            List of output channel sizes to be used in each block for convolutional layers.
        depthwise_padding (`List[int]`, *optional*, defaults to `[]`):
            List of block indices with square padding.
        strides (`List[int]`, *optional*, defaults to `[1, 2, 2, 2, 1, 2, 1]`):
            List of stride sizes to be used in each block for convolutional layers.
        num_block_repeats (`List[int]`, *optional*, defaults to `[1, 2, 2, 3, 3, 4, 1]`):
            List of the number of times each block is to repeated.
        expand_ratios (`List[int]`, *optional*, defaults to `[1, 6, 6, 6, 6, 6, 6]`):
            List of scaling coefficient of each block.
        squeeze_expansion_ratio (`float`, *optional*, defaults to 0.25):
            Squeeze expansion ratio.
        hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
            The non-linear activation function (function or string) in each block. If string, `"gelu"`, `"relu"`,
            `"selu", `"gelu_new"`, `"silu"` and `"mish"` are supported.
        hidden_dim (`int`, *optional*, defaults to 1280):
            The hidden dimension of the layer before the classification head.
        pooling_type (`str` or `function`, *optional*, defaults to `"mean"`):
            Type of final pooling to be applied before the dense classification head. Available options are [`"mean"`,
            `"max"`]
        initializer_range (`float`, *optional*, defaults to 0.02):
            The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
        batch_norm_eps (`float`, *optional*, defaults to 1e-3):
            The epsilon used by the batch normalization layers.
        batch_norm_momentum (`float`, *optional*, defaults to 0.99):
            The momentum used by the batch normalization layers.
        dropout_rate (`float`, *optional*, defaults to 0.5):
            The dropout rate to be applied before final classifier layer.
        drop_connect_rate (`float`, *optional*, defaults to 0.2):
            The drop rate for skip connections.

    Example:
    ```python
    >>> from transformers import EfficientNetConfig, EfficientNetModel

    >>> # Initializing a EfficientNet efficientnet-b7 style configuration
    >>> configuration = EfficientNetConfig()

    >>> # Initializing a model (with random weights) from the efficientnet-b7 style configuration
    >>> model = EfficientNetModel(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```Zefficientnetr   iX  g       @g@   )r   r      r   r   r   r   )          (   P   p      )r   r   r   r   r   r   i@  )      r   r   r   r   r   )r   r   r   r   r      r   )r      r   r   r   r   r   g      ?Zswishi 
  meang{Gz?gMbP?gGz?g      ?g?num_channels
image_sizewidth_coefficientdepth_coefficientdepth_divisorkernel_sizesin_channelsout_channelsdepthwise_paddingstridesnum_block_repeatsexpand_ratiossqueeze_expansion_ratio
hidden_act
hidden_dimpooling_typeinitializer_rangebatch_norm_epsbatch_norm_momentumdropout_ratedrop_connect_ratec                    s   t  jdi | || _|| _|| _|| _|| _|| _|| _|| _	|	| _
|
| _|| _|| _|| _|| _|| _|| _|| _|| _|| _|| _|| _t|d | _d S )Nr    )super__init__r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   sumZnum_hidden_layers)selfr   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   kwargs	__class__r/   j/var/www/auris/lib/python3.10/site-packages/transformers/models/efficientnet/configuration_efficientnet.pyr1   f   s.   zEfficientNetConfig.__init__)__name__
__module____qualname____doc__Z
model_typeintfloatr   strr1   __classcell__r/   r/   r5   r7   r      s    E	
r   c                   @   sJ   e Zd ZedZedeeee	ef f fddZ
edefddZdS )EfficientNetOnnxConfigz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   r3   r/   r/   r7   inputs   s   zEfficientNetOnnxConfig.inputsc                 C   s   dS )Ngh㈵>r/   rE   r/   r/   r7   atol_for_validation   s   z*EfficientNetOnnxConfig.atol_for_validationN)r8   r9   r:   r   parseZtorch_onnx_minimum_versionpropertyr   r>   r<   rF   r=   rG   r/   r/   r/   r7   r@      s    
 r@   N)r;   collectionsr   typingr   r   	packagingr   Zconfiguration_utilsr   Zonnxr	   utilsr
   Z
get_loggerr8   loggerr   r@   __all__r/   r/   r/   r7   <module>   s   
{