






from ...configuration_utils import PretrainedConfig
from ...utils import logging


A_		:		List[str]		     =			logging.get_logger(__name__)

A_		:		Dict		     =			{
    'microsoft/cvt-13': 'https://huggingface.co/microsoft/cvt-13/resolve/main/config.json',
    # See all Cvt models at https://huggingface.co/models?filter=cvt
}




class     _lowerCAmelCase(	UpperCAmelCase_ ):





       """simple docstring"""







       a    :		List[str]									='''cvt'''





       def __init__( self  ,      _lowerCamelCase=3  ,      _lowerCamelCase=[7, 3, 3]  ,      _lowerCamelCase=[4, 2, 2]  ,      _lowerCamelCase=[2, 1, 1]  ,      _lowerCamelCase=[6_4, 1_9_2, 3_8_4]  ,      _lowerCamelCase=[1, 3, 6]  ,      _lowerCamelCase=[1, 2, 1_0]  ,      _lowerCamelCase=[4.0, 4.0, 4.0]  ,      _lowerCamelCase=[0.0, 0.0, 0.0]  ,      _lowerCamelCase=[0.0, 0.0, 0.0]  ,      _lowerCamelCase=[0.0, 0.0, 0.1]  ,      _lowerCamelCase=[True, True, True]  ,      _lowerCamelCase=[False, False, True]  ,      _lowerCamelCase=["dw_bn", "dw_bn", "dw_bn"]  ,      _lowerCamelCase=[3, 3, 3]  ,      _lowerCamelCase=[1, 1, 1]  ,      _lowerCamelCase=[2, 2, 2]  ,      _lowerCamelCase=[1, 1, 1]  ,      _lowerCamelCase=[1, 1, 1]  ,      _lowerCamelCase=0.0_2  ,      _lowerCamelCase=1e-12  ,      **_lowerCamelCase  ,      ):
         super().__init__(**_lowerCamelCase							)
         UpperCamelCase_: Tuple   				=    num_channels
         UpperCamelCase_: Optional[int]   				=    patch_sizes
         UpperCamelCase_: Union[str, Any]   				=    patch_stride
         UpperCamelCase_: List[Any]   				=    patch_padding
         UpperCamelCase_: List[Any]   				=    embed_dim
         UpperCamelCase_: str   				=    num_heads
         UpperCamelCase_: Tuple   				=    depth
         UpperCamelCase_: Dict   				=    mlp_ratio
         UpperCamelCase_: Union[str, Any]   				=    attention_drop_rate
         UpperCamelCase_: int   				=    drop_rate
         UpperCamelCase_: Optional[Any]   				=    drop_path_rate
         UpperCamelCase_: Optional[int]   				=    qkv_bias
         UpperCamelCase_: Tuple   				=    cls_token
         UpperCamelCase_: List[str]   				=    qkv_projection_method
         UpperCamelCase_: Tuple   				=    kernel_qkv
         UpperCamelCase_: Dict   				=    padding_kv
         UpperCamelCase_: Optional[int]   				=    stride_kv
         UpperCamelCase_: Optional[Any]   				=    padding_q
         UpperCamelCase_: Dict   				=    stride_q
         UpperCamelCase_: Union[str, Any]   				=    initializer_range
         UpperCamelCase_: List[Any]   				=    layer_norm_eps







import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_torch


if is_torch_available():
   import torch

   from transformers.activations import gelu_new, gelu_python, get_activation




@require_torch
class     _lowerCAmelCase(	unittest.TestCase ):





       """simple docstring"""







       def       _a   ( self							):
         UpperCamelCase_: Any   				=    torch.tensor([-1_0_0, -1, -0.1, 0, 0.1, 1.0, 1_0_0]							)
         UpperCamelCase_: List[str]   				=    get_activation('gelu'							)
         self.assertTrue(torch.allclose(gelu_python(_lowerCamelCase							)  ,      torch_builtin(_lowerCamelCase							)							)							)
         self.assertFalse(torch.allclose(gelu_python(_lowerCamelCase							)  ,      gelu_new(_lowerCamelCase							)							)							)





       def       _a   ( self							):
         UpperCamelCase_: Optional[Any]   				=    torch.tensor([-1_0_0, -1, -0.1, 0, 0.1, 1.0, 1_0_0]							)
         UpperCamelCase_: Union[str, Any]   				=    get_activation('gelu'							)
         UpperCamelCase_: int   				=    get_activation('gelu_10'							)

         UpperCamelCase_: Union[str, Any]   				=    torch_builtin(_lowerCamelCase							)
         UpperCamelCase_: List[str]   				=    geluaa(_lowerCamelCase							)

         UpperCamelCase_: Dict   				=    torch.where(y_gelu_aa < 1_0.0  ,      1  ,      0							)

         self.assertTrue(torch.max(_lowerCamelCase							).item() == 1_0.0							)
         self.assertTrue(torch.allclose(y_gelu * clipped_mask  ,      y_gelu_aa * clipped_mask							)							)





       def       _a   ( self							):
         get_activation('gelu'							)
         get_activation('gelu_10'							)
         get_activation('gelu_fast'							)
         get_activation('gelu_new'							)
         get_activation('gelu_python'							)
         get_activation('gelu_pytorch_tanh'							)
         get_activation('linear'							)
         get_activation('mish'							)
         get_activation('quick_gelu'							)
         get_activation('relu'							)
         get_activation('sigmoid'							)
         get_activation('silu'							)
         get_activation('swish'							)
         get_activation('tanh'							)
         with self.assertRaises(_lowerCamelCase							):
           get_activation('bogus'							)
         with self.assertRaises(_lowerCamelCase							):
           get_activation(_lowerCamelCase							)





       def       _a   ( self							):
         UpperCamelCase_: str   				=    get_activation('gelu'							)
         UpperCamelCase_: str   				=    1
         UpperCamelCase_: int   				=    get_activation('gelu'							)
         self.assertEqual(acta.a  ,      1							)
         with self.assertRaises(_lowerCamelCase							):
           UpperCamelCase_: Tuple   				=    acta.a