




"""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


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

lowerCAmelCase							:			Union[str, Any]     							=							{
    """debug""": logging.DEBUG,
    """info""": logging.INFO,
    """warning""": logging.WARNING,
    """error""": logging.ERROR,
    """critical""": logging.CRITICAL,
}

lowerCAmelCase							:			Any     							=							logging.WARNING

lowerCAmelCase							:			int     							=							True



def     a__ (				)						->					Dict:
			lowerCamelCase			      =					os.getenv("""TRANSFORMERS_VERBOSITY"""       , snake_case__				)
			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:
			return __name__.split("""."""				)[0]



def     a__ (				)						->					logging.Logger:
			return logging.getLogger(_get_library_name()				)



def     a__ (				)						->					None:
			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     a__ (				)						->					None:
			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     a__ (				)						->					Any:
			return log_levels



def     a__ (				snake_case__ = None				)						->					logging.Logger:

			if name is None:
						lowerCamelCase			      =					_get_library_name()

			_configure_library_root_logger()
			return logging.getLogger(snake_case__				)



def     a__ (				)						->					int:
			_configure_library_root_logger()
			return _get_library_root_logger().getEffectiveLevel()



def     a__ (				snake_case__				)						->					None:
			_configure_library_root_logger()
			_get_library_root_logger().setLevel(snake_case__				)



def     a__ (				)						->					List[Any]:
			return set_verbosity(snake_case__				)



def     a__ (				)						->					Optional[int]:
			return set_verbosity(snake_case__				)



def     a__ (				)						->					Optional[Any]:
			return set_verbosity(snake_case__				)



def     a__ (				)						->					Optional[Any]:
			return set_verbosity(snake_case__				)



def     a__ (				)						->					None:
			_configure_library_root_logger()

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



def     a__ (				)						->					None:
			_configure_library_root_logger()

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



def     a__ (				snake_case__				)						->					None:
			_configure_library_root_logger()

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



def     a__ (				snake_case__				)						->					None:
			_configure_library_root_logger()

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



def     a__ (				)						->					None:
			_configure_library_root_logger()
			lowerCamelCase			      =					False



def     a__ (				)						->					None:
			_configure_library_root_logger()
			lowerCamelCase			      =					True



def     a__ (				)						->					None:
			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(snake_case__				)



def     a__ (				)						->					None:
			lowerCamelCase			      =					_get_library_root_logger().handlers

			for handler in handlers:
						handler.setFormatter(snake_case__				)



def     a__ (				self       , *snake_case__       , **snake_case__				)						->					Tuple:
			lowerCamelCase			      =					os.getenv("""TRANSFORMERS_NO_ADVISORY_WARNINGS"""       , snake_case__				)
			if no_advisory_warnings:
						return
			self.warning(*snake_case__       , **snake_case__				)


lowerCAmelCase							:			List[str]     							=							warning_advice



@functools.lru_cache(snake_case__				)
def     a__ (				self       , *snake_case__       , **snake_case__				)						->					Optional[int]:
			self.warning(*snake_case__       , **snake_case__				)


lowerCAmelCase							:			Optional[int]     							=							warning_once






class     __magic_name__							:






				'''simple docstring'''





				def __init__(       self		, *_a		, **_a ):  # pylint: disable=unused-argument





							"""simple docstring"""
							lowerCamelCase			      =					args[0] if args else None





				def __iter__(       self ):





							"""simple docstring"""
							return iter(self._iterator )





				def __getattr__(       self		, _a ):





							"""simple docstring"""

							def empty_fn(*_a		, **_a ):  # pylint: disable=unused-argument
										return

							return empty_fn





				def __enter__(       self ):





							"""simple docstring"""
							return self





				def __exit__(       self		, _a		, _a		, _a ):





							"""simple docstring"""
							return






class     __magic_name__							:






				'''simple docstring'''





				def __call__(       self		, *_a		, **_a ):





							"""simple docstring"""
							if _tqdm_active:
										return tqdm_lib.tqdm(*_a		, **_a )
							else:
										return EmptyTqdm(*_a		, **_a )





				def    _lowerCAmelCase				(       self		, *_a		, **_a ):





							"""simple docstring"""
							lowerCamelCase			      =					None
							if _tqdm_active:
										return tqdm_lib.tqdm.set_lock(*_a		, **_a )





				def    _lowerCAmelCase				(       self ):





							"""simple docstring"""
							if _tqdm_active:
										return tqdm_lib.tqdm.get_lock()




lowerCAmelCase							:			Optional[int]     							=							_tqdm_cls()



def     a__ (				)						->					bool:
			global _tqdm_active
			return bool(_tqdm_active				)



def     a__ (				)						->					List[Any]:
			global _tqdm_active
			lowerCamelCase			      =					True
			hf_hub_utils.enable_progress_bars()



def     a__ (				)						->					int:
			global _tqdm_active
			lowerCamelCase			      =					False
			hf_hub_utils.disable_progress_bars()









"""simple docstring"""




def     a__ (				snake_case__       , snake_case__ = False				)						->					str:

			if not isinstance(snake_case__       , snake_case__				):
						lowerCamelCase			      =					F'Expected string as input, found {type(snake_case__				)}'
						raise ValueError(snake_case__				)
			if not isinstance(snake_case__       , snake_case__				):
						lowerCamelCase			      =					F'Expected boolean as use_pascal parameter, found {type(snake_case__				)}'
						raise ValueError(snake_case__				)

			lowerCamelCase			      =					input_str.split("""_"""				)

			lowerCamelCase			      =					0 if use_pascal else 1

			lowerCamelCase			      =					words[start_index:]

			lowerCamelCase			      =					[word[0].upper() + word[1:] for word in words_to_capitalize]

			lowerCamelCase			      =					"""""" if use_pascal else words[0]

			return "".join([initial_word, *capitalized_words]				)


if __name__ == "__main__":
					from doctest import testmod

					testmod()



