



'''simple docstring'''





from dataclasses import dataclass, field
from typing import Tuple

from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends
from .benchmark_args_utils import BenchmarkArguments


if is_torch_available():
    import torch

if is_torch_tpu_available(check_device=False):
    import torch_xla.core.xla_model as xm


A__    :   Optional[Any]           =					logging.get_logger(__name__)



@dataclass
class  snake_case__						(    SCREAMING_SNAKE_CASE_				):
 A__				= [
     '''no_inference''',
     '''no_cuda''',
     '''no_tpu''',
     '''no_speed''',
     '''no_memory''',
     '''no_env_print''',
     '''no_multi_process''',
 ]
 def __init__(   self						:							str      ,     **__a						:							Union[str, Any]  )      ->   Dict:







       '''simple docstring'''
       for deprecated_arg in self.deprecated_args:
             if deprecated_arg in kwargs:
                   __snake_case :   Optional[Any]													=    deprecated_arg[3:]
                   setattr(self      ,     __a      ,     not kwargs.pop(__a  )  )
                   logger.warning(
                       f'''{deprecated_arg} is depreciated. Please use --no_{positive_arg} or'''
                       f''' {positive_arg}={kwargs[positive_arg]}'''  )

       __snake_case :   Any													=    kwargs.pop('torchscript'      ,     self.torchscript  )
       __snake_case :   List[str]													=    kwargs.pop('torch_xla_tpu_print_metrics'      ,     self.torch_xla_tpu_print_metrics  )
       __snake_case :   Any													=    kwargs.pop('fp16_opt_level'      ,     self.fpaa_opt_level  )
       super().__init__(**__a  )

 A__				= field(default=SCREAMING_SNAKE_CASE_  ,     metadata={'''help''': '''Trace the models using torchscript'''}				)
 A__				= field(default=SCREAMING_SNAKE_CASE_  ,     metadata={'''help''': '''Print Xla/PyTorch tpu metrics'''}				)
 A__				= field(
     default='''O1'''  ,     metadata={
         '''help''': (
             '''For fp16: Apex AMP optimization level selected in [\'O0\', \'O1\', \'O2\', and \'O3\']. '''
             '''See details at https://nvidia.github.io/apex/amp.html'''
         )
     }  ,     )
 @cached_property
 def A_   (   self						:							List[str]  )      ->   Tuple["torch.device", int]:







       '''simple docstring'''
       requires_backends(self      ,     ['torch']  )
       logger.info('PyTorch: setting up devices'  )
       if not self.cuda:
             __snake_case :   int													=    torch.device('cpu'  )
             __snake_case :   Dict													=    0
       elif is_torch_tpu_available():
             __snake_case :   List[str]													=    xm.xla_device()
             __snake_case :   Optional[int]													=    0
       else:
             __snake_case :   Union[str, Any]													=    torch.device('cuda' if torch.cuda.is_available() else 'cpu'  )
             __snake_case :   Dict													=    torch.cuda.device_count()
       return device, n_gpu
 @property
 def A_   (   self						:							Optional[Any]  )      ->   List[Any]:







       '''simple docstring'''
       return is_torch_tpu_available() and self.tpu
 @property
 def A_   (   self						:							Optional[Any]  )      ->   int:







       '''simple docstring'''
       requires_backends(self      ,     ['torch']  )
       # TODO(PVP): currently only single GPU is supported
       return torch.cuda.current_device()
 @property
 def A_   (   self						:							Tuple  )      ->   "torch.device":







       '''simple docstring'''
       requires_backends(self      ,     ['torch']  )
       return self._setup_devices[0]
 @property
 def A_   (   self						:							Optional[int]  )      ->   Optional[int]:







       '''simple docstring'''
       requires_backends(self      ,     ['torch']  )
       return self._setup_devices[1]





 @property
 def A_   (   self						:							Optional[Any]  )      ->   List[str]:







       '''simple docstring'''
       return self.n_gpu > 0








'''simple docstring'''





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


A__    :   Optional[Any]           =					logging.get_logger(__name__)

A__    :   List[str]           =					{
    '''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  snake_case__						(    SCREAMING_SNAKE_CASE_				):
 A__				= '''cvt'''
 def __init__(   self						:							Optional[Any]      ,     __a						:							Union[str, Any]=3      ,     __a						:							List[Any]=[7, 3, 3]      ,     __a						:							Optional[int]=[4, 2, 2]      ,     __a						:							Dict=[2, 1, 1]      ,     __a						:							Union[str, Any]=[64, 192, 384]      ,     __a						:							int=[1, 3, 6]      ,     __a						:							List[str]=[1, 2, 10]      ,     __a						:							Optional[Any]=[4.0, 4.0, 4.0]      ,     __a						:							Any=[0.0, 0.0, 0.0]      ,     __a						:							List[str]=[0.0, 0.0, 0.0]      ,     __a						:							List[Any]=[0.0, 0.0, 0.1]      ,     __a						:							List[str]=[True, True, True]      ,     __a						:							int=[False, False, True]      ,     __a						:							Dict=["dw_bn", "dw_bn", "dw_bn"]      ,     __a						:							List[str]=[3, 3, 3]      ,     __a						:							Union[str, Any]=[1, 1, 1]      ,     __a						:							Optional[int]=[2, 2, 2]      ,     __a						:							Optional[Any]=[1, 1, 1]      ,     __a						:							List[str]=[1, 1, 1]      ,     __a						:							List[str]=0.0_2      ,     __a						:							List[str]=1e-12      ,     **__a						:							List[str]      ,     )      ->   Dict:







       '''simple docstring'''
       super().__init__(**__a  )
       __snake_case :   int													=    num_channels
       __snake_case :   Union[str, Any]													=    patch_sizes
       __snake_case :   Any													=    patch_stride
       __snake_case :   List[str]													=    patch_padding
       __snake_case :   Optional[Any]													=    embed_dim
       __snake_case :   Union[str, Any]													=    num_heads
       __snake_case :   Dict													=    depth
       __snake_case :   Optional[Any]													=    mlp_ratio
       __snake_case :   List[str]													=    attention_drop_rate
       __snake_case :   Optional[int]													=    drop_rate
       __snake_case :   Optional[int]													=    drop_path_rate
       __snake_case :   Any													=    qkv_bias
       __snake_case :   int													=    cls_token
       __snake_case :   Optional[int]													=    qkv_projection_method
       __snake_case :   List[Any]													=    kernel_qkv
       __snake_case :   List[Any]													=    padding_kv
       __snake_case :   int													=    stride_kv
       __snake_case :   List[str]													=    padding_q
       __snake_case :   Dict													=    stride_q
       __snake_case :   Tuple													=    initializer_range
       __snake_case :   List[Any]													=    layer_norm_eps



