

"""simple docstring"""





import functools
import logging
import os
import sys
import threading
from logging import (
    CRITICAL,  # NOQA
    DEBUG,  # NOQA
    ERROR,  # NOQA
    FATAL,  # NOQA
    INFO,  # NOQA
    NOTSET,  # NOQA
    WARN,  # NOQA
    WARNING,  # NOQA
)
from typing import Optional

import huggingface_hub.utils as hf_hub_utils
from tqdm import auto as tqdm_lib


_a       =							threading.Lock()
_a       =							None

_a       =							{
    'debug': logging.DEBUG,
    'info': logging.INFO,
    'warning': logging.WARNING,
    'error': logging.ERROR,
    'critical': logging.CRITICAL,
}

_a       =							logging.WARNING

_a       =							True




def   _A  (  )	->						List[str]:
   '''simple docstring'''


   __lowercase								=						os.getenv("TRANSFORMERS_VERBOSITY",			UpperCamelCase_)
   if env_level_str:
      if env_level_str in log_levels:
         return log_levels[env_level_str]
      else:
         logging.getLogger().warning(
             F"""Unknown option TRANSFORMERS_VERBOSITY={env_level_str}, """
             F"""has to be one of: { ", ".join(log_levels.keys()) }""")
   return _default_log_level




def   _A  (  )	->						str:
   '''simple docstring'''


   return __name__.split(".")[0]




def   _A  (  )	->						logging.Logger:
   '''simple docstring'''


   return logging.getLogger(_get_library_name())




def   _A  (  )	->						None:
   '''simple docstring'''


   global _default_handler

   with _lock:
      if _default_handler:
         # This library has already configured the library root logger.
         return
      __lowercase								=						logging.StreamHandler()  # Set sys.stderr as stream.
      __lowercase								=						sys.stderr.flush

      # Apply our default configuration to the library root logger.
      __lowercase								=						_get_library_root_logger()
      library_root_logger.addHandler(_default_handler)
      library_root_logger.setLevel(_get_default_logging_level())
      __lowercase								=						False




def   _A  (  )	->						None:
   '''simple docstring'''


   global _default_handler

   with _lock:
      if not _default_handler:
         return

      __lowercase								=						_get_library_root_logger()
      library_root_logger.removeHandler(_default_handler)
      library_root_logger.setLevel(logging.NOTSET)
      __lowercase								=						None




def   _A  (  )	->						int:
   '''simple docstring'''


   return log_levels




def   _A  (  UpperCamelCase_     :       Optional[str] = None)	->						logging.Logger:
   '''simple docstring'''


   if name is None:
      __lowercase								=						_get_library_name()

   _configure_library_root_logger()
   return logging.getLogger(UpperCamelCase_)




def   _A  (  )	->						int:
   '''simple docstring'''


   _configure_library_root_logger()
   return _get_library_root_logger().getEffectiveLevel()




def   _A  (  UpperCamelCase_     :       int)	->						None:
   '''simple docstring'''


   _configure_library_root_logger()
   _get_library_root_logger().setLevel(UpperCamelCase_)




def   _A  (  )	->						Union[str, Any]:
   '''simple docstring'''


   return set_verbosity(UpperCamelCase_)




def   _A  (  )	->						Optional[Any]:
   '''simple docstring'''


   return set_verbosity(UpperCamelCase_)




def   _A  (  )	->						Dict:
   '''simple docstring'''


   return set_verbosity(UpperCamelCase_)




def   _A  (  )	->						List[str]:
   '''simple docstring'''


   return set_verbosity(UpperCamelCase_)




def   _A  (  )	->						None:
   '''simple docstring'''


   _configure_library_root_logger()

   assert _default_handler is not None
   _get_library_root_logger().removeHandler(_default_handler)




def   _A  (  )	->						None:
   '''simple docstring'''


   _configure_library_root_logger()

   assert _default_handler is not None
   _get_library_root_logger().addHandler(_default_handler)




def   _A  (  UpperCamelCase_     :       logging.Handler)	->						None:
   '''simple docstring'''


   _configure_library_root_logger()

   assert handler is not None
   _get_library_root_logger().addHandler(UpperCamelCase_)




def   _A  (  UpperCamelCase_     :       logging.Handler)	->						None:
   '''simple docstring'''


   _configure_library_root_logger()

   assert handler is not None and handler not in _get_library_root_logger().handlers
   _get_library_root_logger().removeHandler(UpperCamelCase_)




def   _A  (  )	->						None:
   '''simple docstring'''


   _configure_library_root_logger()
   __lowercase								=						False




def   _A  (  )	->						None:
   '''simple docstring'''


   _configure_library_root_logger()
   __lowercase								=						True




def   _A  (  )	->						None:
   '''simple docstring'''


   __lowercase								=						_get_library_root_logger().handlers

   for handler in handlers:
      __lowercase								=						logging.Formatter("[%(levelname)s|%(filename)s:%(lineno)s] %(asctime)s >> %(message)s")
      handler.setFormatter(UpperCamelCase_)




def   _A  (  )	->						None:
   '''simple docstring'''


   __lowercase								=						_get_library_root_logger().handlers

   for handler in handlers:
      handler.setFormatter(UpperCamelCase_)




def   _A  (  self     :       Optional[int],			*UpperCamelCase_     :       Optional[Any],			**UpperCamelCase_     :       List[str])	->						Union[str, Any]:
   '''simple docstring'''


   __lowercase								=						os.getenv("TRANSFORMERS_NO_ADVISORY_WARNINGS",			UpperCamelCase_)
   if no_advisory_warnings:
      return
   self.warning(*UpperCamelCase_,			**UpperCamelCase_)


_a       =							warning_advice




@functools.lru_cache(UpperCamelCase_)
def   _A  (  self     :       Optional[Any],			*UpperCamelCase_     :       List[str],			**UpperCamelCase_     :       List[str])	->						Any:
   '''simple docstring'''


   self.warning(*UpperCamelCase_,			**UpperCamelCase_)


_a       =							warning_once




class 					_lowerCAmelCase  :







 """simple docstring"""







 def __init__(			self							:			Optional[Any],					*UpperCAmelCase__							:			int,					**UpperCAmelCase__							:			Optional[int]	):  # pylint: disable=unused-argument
    __lowercase								=						args[0] if args else None


 def __iter__(			self							:			Dict	):
    return iter(self._iterator	)


 def __getattr__(			self							:			int,					UpperCAmelCase__							:			int	):

    def empty_fn(*UpperCAmelCase__							:			Optional[Any],					**UpperCAmelCase__							:			Tuple	):  # pylint: disable=unused-argument
       return

    return empty_fn


 def __enter__(			self							:			List[Any]	):
    return self



 def __exit__(			self							:			List[str],					UpperCAmelCase__							:			Union[str, Any],					UpperCAmelCase__							:			Dict,					UpperCAmelCase__							:			Union[str, Any]	):
    return







class 					_lowerCAmelCase  :







 """simple docstring"""







 def __call__(			self							:			Union[str, Any],					*UpperCAmelCase__							:			Dict,					**UpperCAmelCase__							:			Any	):
    if _tqdm_active:
       return tqdm_lib.tqdm(*UpperCAmelCase__,					**UpperCAmelCase__	)
    else:
       return EmptyTqdm(*UpperCAmelCase__,					**UpperCAmelCase__	)


 def 					_lowercase (			self							:			Optional[int],					*UpperCAmelCase__							:			Optional[int],					**UpperCAmelCase__							:			Union[str, Any]	):
    __lowercase								=						None
    if _tqdm_active:
       return tqdm_lib.tqdm.set_lock(*UpperCAmelCase__,					**UpperCAmelCase__	)



 def 					_lowercase (			self							:			List[str]	):
    if _tqdm_active:
       return tqdm_lib.tqdm.get_lock()







_a       =							_tqdm_cls()




def   _A  (  )	->						bool:
   '''simple docstring'''


   global _tqdm_active
   return bool(_tqdm_active)




def   _A  (  )	->						Dict:
   '''simple docstring'''


   global _tqdm_active
   __lowercase								=						True
   hf_hub_utils.enable_progress_bars()




def   _A  (  )	->						Tuple:
   '''simple docstring'''


   global _tqdm_active
   __lowercase								=						False
   hf_hub_utils.disable_progress_bars()






from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


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

A     :	Optional[int]    = {
    'facebook/levit-128S': 'https://huggingface.co/facebook/levit-128S/resolve/main/config.json',
    # See all LeViT models at https://huggingface.co/models?filter=levit
}







class 			__A( a			):
				snake_case_						   =    '''levit'''




				def __init__(     self		,     _snake_case=224		,     _snake_case=3		,     _snake_case=3		,     _snake_case=2		,     _snake_case=1		,     _snake_case=16		,     _snake_case=[128, 256, 384]		,     _snake_case=[4, 8, 12]		,     _snake_case=[4, 4, 4]		,     _snake_case=[16, 16, 16]		,     _snake_case=0		,     _snake_case=[2, 2, 2]		,     _snake_case=[2, 2, 2]		,     _snake_case=0.02		,     **_snake_case		,     )    ->      Optional[Any]:


								'''simple docstring'''




								super().__init__(**_snake_case				)
								__a										=    image_size
								__a										=    num_channels
								__a										=    kernel_size
								__a										=    stride
								__a										=    padding
								__a										=    hidden_sizes
								__a										=    num_attention_heads
								__a										=    depths
								__a										=    key_dim
								__a										=    drop_path_rate
								__a										=    patch_size
								__a										=    attention_ratio
								__a										=    mlp_ratio
								__a										=    initializer_range
								__a										=    [
								    ['''Subsample''', key_dim[0], hidden_sizes[0] // key_dim[0], 4, 2, 2],
								    ['''Subsample''', key_dim[0], hidden_sizes[1] // key_dim[0], 4, 2, 2],
								]







class 			__A( a			):
				snake_case_						   =    version.parse('''1.11'''			)




				@property
				def 				SCREAMING_SNAKE_CASE_		(     self				)    ->      Mapping[str, Mapping[int, str]]:


								'''simple docstring'''




								return OrderedDict(
								    [
								        ('''pixel_values''', {0: '''batch''', 1: '''num_channels''', 2: '''height''', 3: '''width'''}),
								    ]				)




				@property
				def 				SCREAMING_SNAKE_CASE_		(     self				)    ->      float:


								'''simple docstring'''




								return 1E-4