




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


lowerCamelCase       :	List[str]									=     threading.Lock()
lowerCamelCase       :	Optional[logging.Handler]									=     None

lowerCamelCase       :	int									=     {
    "debug": logging.DEBUG,
    "info": logging.INFO,
    "warning": logging.WARNING,
    "error": logging.ERROR,
    "critical": logging.CRITICAL,
}

lowerCamelCase       :	str									=     logging.WARNING

lowerCamelCase       :	List[str]									=     True

def     _SCREAMING_SNAKE_CASE    (							):


						'''simple docstring'''



						lowerCamelCase_	  =					os.getenv('TRANSFORMERS_VERBOSITY'			,							lowercase  )
						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     _SCREAMING_SNAKE_CASE    (							):


						'''simple docstring'''



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

def     _SCREAMING_SNAKE_CASE    (							):


						'''simple docstring'''



						return logging.getLogger(_get_library_name()  )

def     _SCREAMING_SNAKE_CASE    (							):


						'''simple docstring'''



						global _default_handler

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

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

def     _SCREAMING_SNAKE_CASE    (							):


						'''simple docstring'''



						global _default_handler

						with _lock:
												if not _default_handler:
																		return

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

def     _SCREAMING_SNAKE_CASE    (							):


						'''simple docstring'''



						return log_levels

def     _SCREAMING_SNAKE_CASE    (							lowercase			: Optional[str] = None  ):


						'''simple docstring'''



						if name is None:
												lowerCamelCase_	  =					_get_library_name()

						_configure_library_root_logger()
						return logging.getLogger(lowercase  )

def     _SCREAMING_SNAKE_CASE    (							):


						'''simple docstring'''



						_configure_library_root_logger()
						return _get_library_root_logger().getEffectiveLevel()

def     _SCREAMING_SNAKE_CASE    (							lowercase			: int  ):


						'''simple docstring'''



						_configure_library_root_logger()
						_get_library_root_logger().setLevel(lowercase  )

def     _SCREAMING_SNAKE_CASE    (							):


						'''simple docstring'''



						return set_verbosity(lowercase  )

def     _SCREAMING_SNAKE_CASE    (							):


						'''simple docstring'''



						return set_verbosity(lowercase  )

def     _SCREAMING_SNAKE_CASE    (							):


						'''simple docstring'''



						return set_verbosity(lowercase  )

def     _SCREAMING_SNAKE_CASE    (							):


						'''simple docstring'''



						return set_verbosity(lowercase  )

def     _SCREAMING_SNAKE_CASE    (							):


						'''simple docstring'''



						_configure_library_root_logger()

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

def     _SCREAMING_SNAKE_CASE    (							):


						'''simple docstring'''



						_configure_library_root_logger()

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

def     _SCREAMING_SNAKE_CASE    (							lowercase			: logging.Handler  ):


						'''simple docstring'''



						_configure_library_root_logger()

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

def     _SCREAMING_SNAKE_CASE    (							lowercase			: logging.Handler  ):


						'''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(lowercase  )

def     _SCREAMING_SNAKE_CASE    (							):


						'''simple docstring'''



						_configure_library_root_logger()
						lowerCamelCase_	  =					False

def     _SCREAMING_SNAKE_CASE    (							):


						'''simple docstring'''



						_configure_library_root_logger()
						lowerCamelCase_	  =					True

def     _SCREAMING_SNAKE_CASE    (							):


						'''simple docstring'''



						lowerCamelCase_	  =					_get_library_root_logger().handlers

						for handler in handlers:
												lowerCamelCase_	  =					logging.Formatter('[%(levelname)s|%(filename)s:%(lineno)s] %(asctime)s >> %(message)s'  )
												handler.setFormatter(lowercase  )

def     _SCREAMING_SNAKE_CASE    (							):


						'''simple docstring'''



						lowerCamelCase_	  =					_get_library_root_logger().handlers

						for handler in handlers:
												handler.setFormatter(lowercase  )

def     _SCREAMING_SNAKE_CASE    (							self			: List[str]			,							*lowercase			: List[str]			,							**lowercase			: str  ):


						'''simple docstring'''



						lowerCamelCase_	  =					os.getenv('TRANSFORMERS_NO_ADVISORY_WARNINGS'			,							lowercase  )
						if no_advisory_warnings:
												return
						self.warning(*lowercase			,							**lowercase  )


lowerCamelCase       :	Optional[Any]									=     warning_advice

@functools.lru_cache(lowercase  )
def     _SCREAMING_SNAKE_CASE    (							self			: Any			,							*lowercase			: Any			,							**lowercase			: Union[str, Any]  ):


						'''simple docstring'''



						self.warning(*lowercase			,							**lowercase  )


lowerCamelCase       :	Optional[int]									=     warning_once







class 						A:



	'''simple docstring'''


	def __init__(       self      :						List[str]		,							*A_      :						Tuple		,							**A_      :						Any						)     ->			List[str]:  # pylint: disable=unused-argument

							"""simple docstring"""






							lowerCamelCase_	  =					args[0] if args else None

	def __iter__(       self      :						str						)     ->			List[Any]:

							"""simple docstring"""






							return iter(self._iterator						)

	def __getattr__(       self      :						Tuple		,							A_      :						str						)     ->			List[Any]:

							"""simple docstring"""






							def empty_fn(*A_      :						List[Any]		,							**A_      :						Optional[int]						):  # pylint: disable=unused-argument
													return

							return empty_fn

	def __enter__(       self      :						Dict						)     ->			int:

							"""simple docstring"""






							return self





	def __exit__(       self      :						Optional[int]		,							A_      :						str		,							A_      :						int		,							A_      :						str						)     ->			Tuple:

							"""simple docstring"""






							return







class 						A:



	'''simple docstring'''


	def __call__(       self      :						Tuple		,							*A_      :						Union[str, Any]		,							**A_      :						int						)     ->			List[str]:

							"""simple docstring"""






							if _tqdm_active:
													return tqdm_lib.tqdm(*A_		,							**A_						)
							else:
													return EmptyTqdm(*A_		,							**A_						)

	def        a__				(       self      :						Tuple		,							*A_      :						Dict		,							**A_      :						Union[str, Any]						)     ->			Optional[int]:

							"""simple docstring"""






							lowerCamelCase_	  =					None
							if _tqdm_active:
													return tqdm_lib.tqdm.set_lock(*A_		,							**A_						)





	def        a__				(       self      :						Union[str, Any]						)     ->			Dict:

							"""simple docstring"""






							if _tqdm_active:
													return tqdm_lib.tqdm.get_lock()

lowerCamelCase       :	List[Any]									=     _tqdm_cls()

def     _SCREAMING_SNAKE_CASE    (							):


						'''simple docstring'''



						global _tqdm_active
						return bool(_tqdm_active  )

def     _SCREAMING_SNAKE_CASE    (							):


						'''simple docstring'''



						global _tqdm_active
						lowerCamelCase_	  =					True
						hf_hub_utils.enable_progress_bars()






def     _SCREAMING_SNAKE_CASE    (							):


						'''simple docstring'''



						global _tqdm_active
						lowerCamelCase_	  =					False
						hf_hub_utils.disable_progress_bars()









from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_torch_available,
    is_vision_available,
)


lowerCamelCase       :	Dict									=     {"configuration_vit": ["VIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "ViTConfig", "ViTOnnxConfig"]}

try:
 if not is_vision_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCamelCase       :	Optional[int]									=     ["ViTFeatureExtractor"]
 lowerCamelCase       :	Dict									=     ["ViTImageProcessor"]

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCamelCase       :	int									=     [
     "VIT_PRETRAINED_MODEL_ARCHIVE_LIST",
     "ViTForImageClassification",
     "ViTForMaskedImageModeling",
     "ViTModel",
     "ViTPreTrainedModel",
 ]

try:
 if not is_tf_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCamelCase       :	Tuple									=     [
     "TFViTForImageClassification",
     "TFViTModel",
     "TFViTPreTrainedModel",
 ]

try:
 if not is_flax_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCamelCase       :	Dict									=     [
     "FlaxViTForImageClassification",
     "FlaxViTModel",
     "FlaxViTPreTrainedModel",
 ]

if TYPE_CHECKING:
 from .configuration_vit import VIT_PRETRAINED_CONFIG_ARCHIVE_MAP, ViTConfig, ViTOnnxConfig

 try:
  if not is_vision_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .feature_extraction_vit import ViTFeatureExtractor
  from .image_processing_vit import ViTImageProcessor

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_vit import (
      VIT_PRETRAINED_MODEL_ARCHIVE_LIST,
      ViTForImageClassification,
      ViTForMaskedImageModeling,
      ViTModel,
      ViTPreTrainedModel,
  )

 try:
  if not is_tf_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_tf_vit import TFViTForImageClassification, TFViTModel, TFViTPreTrainedModel

 try:
  if not is_flax_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_flax_vit import FlaxViTForImageClassification, FlaxViTModel, FlaxViTPreTrainedModel


else:
 import sys

 lowerCamelCase       :	Any									=     _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)



