'''simple docstring'''




from importlib import import_module

from .logging import get_logger


_a   :	Union[str, Any] 							=   get_logger(__name__)






class 		__A       :






       def __init__(      self				,     UpperCamelCase_				,     UpperCamelCase_=None      ):
              __UpperCAmelCase  :				Union[str, Any]       				=		attrs or []
              if module is not None:
                     for key in module.__dict__:
                            if key in attrs or not key.startswith("__"      ):
                                   setattr(self				,     lowerCamelCase_				,     getattr(lowerCamelCase_				,     lowerCamelCase_      )      )
              __UpperCAmelCase  :				Any       				=		module._original_module if isinstance(lowerCamelCase_				,     _PatchedModuleObj      ) else module






class 		__A       :
       snake_case       :Tuple				    =					[]






       def __init__(      self				,     UpperCamelCase_				,     UpperCamelCase_				,     UpperCamelCase_				,     UpperCamelCase_=None      ):
              __UpperCAmelCase  :				List[str]       				=		obj
              __UpperCAmelCase  :				List[Any]       				=		target
              __UpperCAmelCase  :				int       				=		new
              __UpperCAmelCase  :				List[Any]       				=		target.split("."      )[0]
              __UpperCAmelCase  :				Optional[Any]       				=		{}
              __UpperCAmelCase  :				List[str]       				=		attrs or []






       def __enter__(      self      ):
              __UpperCAmelCase  :				Union[str, Any]       				=		self.target.split("."      )

              # Patch modules:
              # it's used to patch attributes of submodules like "os.path.join";
              # in this case we need to patch "os" and "os.path"

              for i in range(len(lowerCamelCase_      )      ):
                     try:
                            __UpperCAmelCase  :				Optional[Any]       				=		import_module(".".join(submodules[: i + 1]      )      )
                     except ModuleNotFoundError:
                            continue
                     # We iterate over all the globals in self.obj in case we find "os" or "os.path"
                     for attr in self.obj.__dir__():
                            __UpperCAmelCase  :				Optional[Any]       				=		getattr(self.obj				,     lowerCamelCase_      )
                            # We don't check for the name of the global, but rather if its value *is* "os" or "os.path".
                            # This allows to patch renamed modules like "from os import path as ospath".
                            if obj_attr is submodule or (
                                (isinstance(lowerCamelCase_				,     _PatchedModuleObj      ) and obj_attr._original_module is submodule)
                            ):
                                   __UpperCAmelCase  :				Optional[int]       				=		obj_attr
                                   # patch at top level
                                   setattr(self.obj				,     lowerCamelCase_				,     _PatchedModuleObj(lowerCamelCase_				,     attrs=self.attrs      )      )
                                   __UpperCAmelCase  :				Optional[int]       				=		getattr(self.obj				,     lowerCamelCase_      )
                                   # construct lower levels patches
                                   for key in submodules[i + 1 :]:
                                          setattr(lowerCamelCase_				,     lowerCamelCase_				,     _PatchedModuleObj(getattr(lowerCamelCase_				,     lowerCamelCase_				,     lowerCamelCase_      )				,     attrs=self.attrs      )      )
                                          __UpperCAmelCase  :				Optional[Any]       				=		getattr(lowerCamelCase_				,     lowerCamelCase_      )
                                   # finally set the target attribute
                                   setattr(lowerCamelCase_				,     lowerCamelCase_				,     self.new      )

        # Patch attribute itself:
        # it's used for builtins like "open",
        # and also to patch "os.path.join" we may also need to patch "join"
        # itself if it was imported as "from os.path import join".

              if submodules:  # if it's an attribute of a submodule like "os.path.join"
                     try:
                            __UpperCAmelCase  :				str       				=		getattr(import_module(".".join(lowerCamelCase_      )      )				,     lowerCamelCase_      )
                     except (AttributeError, ModuleNotFoundError):
                            return
                     # We iterate over all the globals in self.obj in case we find "os.path.join"
                     for attr in self.obj.__dir__():
                            # We don't check for the name of the global, but rather if its value *is* "os.path.join".
                            # This allows to patch renamed attributes like "from os.path import join as pjoin".
                            if getattr(self.obj				,     lowerCamelCase_      ) is attr_value:
                                   __UpperCAmelCase  :				Optional[int]       				=		getattr(self.obj				,     lowerCamelCase_      )
                                   setattr(self.obj				,     lowerCamelCase_				,     self.new      )
              elif target_attr in globals()["__builtins__"]:  # if it'a s builtin like "open"
                     __UpperCAmelCase  :				Union[str, Any]       				=		globals()["""__builtins__"""][target_attr]
                     setattr(self.obj				,     lowerCamelCase_				,     self.new      )
              else:
                     raise RuntimeError(f"""Tried to patch attribute {target_attr} instead of a submodule."""      )






       def __exit__(      self				,     *UpperCamelCase_      ):



              for attr in list(self.original      ):
                     setattr(self.obj				,     lowerCamelCase_				,     self.original.pop(lowerCamelCase_      )      )






       def 			_snake_case						(      self      ):
              self.__enter__()
              self._active_patches.append(self      )







       def 			_snake_case						(      self      ):



              try:
                     self._active_patches.remove(self      )
              except ValueError:
                     # If the patch hasn't been started this will fail
                     return None

              return self.__exit__()







'''simple docstring'''




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


_a   :	Any 							=   logging.get_logger(__name__)

_a   :	List[Any] 							=   {
    "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 		__A       (__magic_name__   ):
       snake_case       :Any				    =					"cvt"






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






