

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


_lowercase   :	Optional[int]												=						threading.Lock()
_lowercase   :	Optional[logging.Handler]												=						None

_lowercase   :	List[str]												=						{
    'debug': logging.DEBUG,
    'info': logging.INFO,
    'warning': logging.WARNING,
    'error': logging.ERROR,
    'critical': logging.CRITICAL,
}

_lowercase   :	Optional[int]												=						logging.WARNING

_lowercase   :	Optional[int]												=						True





def       lowercase__						(       ):
	__UpperCAmelCase      		= 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       lowercase__						(       ):
	return __name__.split('''.'''    )[0]





def       lowercase__						(       ):
	return logging.getLogger(_get_library_name()    )





def       lowercase__						(       ):
	global _default_handler

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

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





def       lowercase__						(       ):
	global _default_handler

	with _lock:
		if not _default_handler:
			return

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





def       lowercase__						(       ):
	return log_levels





def       lowercase__						(       snake_case_   :Optional[str] = None    ):

	if name is None:
		__UpperCAmelCase      		= _get_library_name()

	_configure_library_root_logger()
	return logging.getLogger(snake_case_    )





def       lowercase__						(       ):
	_configure_library_root_logger()
	return _get_library_root_logger().getEffectiveLevel()





def       lowercase__						(       snake_case_   :int    ):
	_configure_library_root_logger()
	_get_library_root_logger().setLevel(snake_case_    )





def       lowercase__						(       ):
	return set_verbosity(snake_case_    )





def       lowercase__						(       ):
	return set_verbosity(snake_case_    )





def       lowercase__						(       ):
	return set_verbosity(snake_case_    )





def       lowercase__						(       ):
	return set_verbosity(snake_case_    )





def       lowercase__						(       ):
	_configure_library_root_logger()

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





def       lowercase__						(       ):
	_configure_library_root_logger()

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





def       lowercase__						(       snake_case_   :logging.Handler    ):
	_configure_library_root_logger()

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





def       lowercase__						(       snake_case_   :logging.Handler    ):
	_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       lowercase__						(       ):
	_configure_library_root_logger()
	__UpperCAmelCase      		= False





def       lowercase__						(       ):
	_configure_library_root_logger()
	__UpperCAmelCase      		= True





def       lowercase__						(       ):
	__UpperCAmelCase      		= _get_library_root_logger().handlers

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





def       lowercase__						(       ):
	__UpperCAmelCase      		= _get_library_root_logger().handlers

	for handler in handlers:
		handler.setFormatter(snake_case_    )





def       lowercase__						(       self   :List[str]			,		*snake_case_   :Dict			,		**snake_case_   :int    ):
	__UpperCAmelCase      		= os.getenv('''TRANSFORMERS_NO_ADVISORY_WARNINGS'''			,		snake_case_    )
	if no_advisory_warnings:
		return
	self.warning(*snake_case_			,		**snake_case_    )


_lowercase   :	str												=						warning_advice





@functools.lru_cache(snake_case_    )
def       lowercase__						(       self   :Union[str, Any]			,		*snake_case_   :Union[str, Any]			,		**snake_case_   :List[str]    ):
	self.warning(*snake_case_			,		**snake_case_    )


_lowercase   :	str												=						warning_once
class      _UpperCAmelCase   :



	def __init__(  self     :       str			,    *_lowercase     :       int			,    **_lowercase     :       str						):  # pylint: disable=unused-argument
		__UpperCAmelCase      		= args[0] if args else None



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



	def __getattr__(  self     :       Any			,    _lowercase     :       Optional[int]						):

		def empty_fn(*_lowercase     :       List[str]			,    **_lowercase     :       Union[str, Any]						):  # pylint: disable=unused-argument
			return

		return empty_fn



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



	def __exit__(  self     :       List[Any]			,    _lowercase     :       Tuple			,    _lowercase     :       List[Any]			,    _lowercase     :       Dict						):
		return






class      _UpperCAmelCase   :



	def __call__(  self     :       int			,    *_lowercase     :       Optional[int]			,    **_lowercase     :       List[Any]						):
		if _tqdm_active:
			return tqdm_lib.tqdm(*_lowercase			,    **_lowercase						)
		else:
			return EmptyTqdm(*_lowercase			,    **_lowercase						)



	def        a  (  self     :       Optional[int]			,    *_lowercase     :       Optional[int]			,    **_lowercase     :       Any						):
		__UpperCAmelCase      		= None
		if _tqdm_active:
			return tqdm_lib.tqdm.set_lock(*_lowercase			,    **_lowercase						)



	def        a  (  self     :       Union[str, Any]						):
		if _tqdm_active:
			return tqdm_lib.tqdm.get_lock()






_lowercase   :	Optional[Any]												=						_tqdm_cls()





def       lowercase__						(       ):
	global _tqdm_active
	return bool(_tqdm_active    )





def       lowercase__						(       ):
	global _tqdm_active
	__UpperCAmelCase      		= True
	hf_hub_utils.enable_progress_bars()





def       lowercase__						(       ):
	global _tqdm_active
	__UpperCAmelCase      		= False
	hf_hub_utils.disable_progress_bars()




'''simple docstring'''





from ..utils import DummyObject, requires_backends




class 				UpperCAmelCase			(			metaclass=_snake_case						):
 UpperCAmelCase				=					["note_seq"]


 def __init__(      self							:	List[str]			,       *__lowerCamelCase							:	int			,       **__lowerCamelCase							:	Optional[int] ):
    requires_backends(self			,       ['''note_seq'''] )


 @classmethod
 def        __SCREAMING_SNAKE_CASE					(      cls							:	Optional[Any]			,       *__lowerCamelCase							:	Dict			,       **__lowerCamelCase							:	Optional[Any] ):
    requires_backends(cls			,       ['''note_seq'''] )





 @classmethod
 def        __SCREAMING_SNAKE_CASE					(      cls							:	str			,       *__lowerCamelCase							:	Any			,       **__lowerCamelCase							:	Optional[Any] ):
    requires_backends(cls			,       ['''note_seq'''] )



