






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


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

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

UpperCAmelCase_     :				Optional[Any]         =				logging.WARNING

UpperCAmelCase_     :				Any         =				True



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






    SCREAMING_SNAKE_CASE_   :						int							=	os.getenv('''TRANSFORMERS_VERBOSITY'''					,       __a							)
    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
        SCREAMING_SNAKE_CASE_   :						List[str]							=	logging.StreamHandler()  # Set sys.stderr as stream.
        SCREAMING_SNAKE_CASE_   :						Optional[Any]							=	sys.stderr.flush

        # Apply our default configuration to the library root logger.
        SCREAMING_SNAKE_CASE_   :						Union[str, Any]							=	_get_library_root_logger()
        library_root_logger.addHandler(_default_handler							)
        library_root_logger.setLevel(_get_default_logging_level()							)
        SCREAMING_SNAKE_CASE_   :						Union[str, Any]							=	False



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






    global _default_handler

    with _lock:
        if not _default_handler:
            return

        SCREAMING_SNAKE_CASE_   :						Dict							=	_get_library_root_logger()
        library_root_logger.removeHandler(_default_handler							)
        library_root_logger.setLevel(logging.NOTSET							)
        SCREAMING_SNAKE_CASE_   :						Union[str, Any]							=	None



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






    return log_levels



def       _A    (__a = None							)				-> logging.Logger:
    """simple docstring"""






    if name is None:
        SCREAMING_SNAKE_CASE_   :						Optional[int]							=	_get_library_name()

    _configure_library_root_logger()
    return logging.getLogger(__a							)



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






    _configure_library_root_logger()
    return _get_library_root_logger().getEffectiveLevel()



def       _A    (__a							)				-> None:
    """simple docstring"""






    _configure_library_root_logger()
    _get_library_root_logger().setLevel(__a							)



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






    return set_verbosity(__a							)



def       _A    ()				-> Optional[int]:
    """simple docstring"""






    return set_verbosity(__a							)



def       _A    ()				-> Any:
    """simple docstring"""






    return set_verbosity(__a							)



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






    return set_verbosity(__a							)



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    (__a							)				-> None:
    """simple docstring"""






    _configure_library_root_logger()

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



def       _A    (__a							)				-> 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(__a							)



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






    _configure_library_root_logger()
    SCREAMING_SNAKE_CASE_   :						Union[str, Any]							=	False



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






    _configure_library_root_logger()
    SCREAMING_SNAKE_CASE_   :						str							=	True



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






    SCREAMING_SNAKE_CASE_   :						Any							=	_get_library_root_logger().handlers

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



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






    SCREAMING_SNAKE_CASE_   :						List[Any]							=	_get_library_root_logger().handlers

    for handler in handlers:
        handler.setFormatter(__a							)



def       _A    (self					,       *__a					,       **__a							)				-> Tuple:
    """simple docstring"""






    SCREAMING_SNAKE_CASE_   :						Dict							=	os.getenv('''TRANSFORMERS_NO_ADVISORY_WARNINGS'''					,       __a							)
    if no_advisory_warnings:
        return
    self.warning(*__a					,       **__a							)


UpperCAmelCase_     :				Any         =				warning_advice



@functools.lru_cache(__a							)
def       _A    (self					,       *__a					,       **__a							)				-> Tuple:
    """simple docstring"""






    self.warning(*__a					,       **__a							)


UpperCAmelCase_     :				Optional[int]         =				warning_once




class 							lowerCAmelCase__       :






      '''simple docstring'''

      def __init__(		self  :						Dict		,			*lowercase_  :						Any		,			**lowercase_  :						int):  # pylint: disable=unused-argument




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_   :						List[Any]							=	args[0] if args else None
      def __iter__(		self  :						int):




          '''simple docstring'''


          return iter(self._iterator)
      def __getattr__(		self  :						Optional[int]		,			lowercase_  :						List[str]):




          '''simple docstring'''


          def empty_fn(*lowercase_  :						List[Any]		,			**lowercase_  :						Dict):  # pylint: disable=unused-argument
              return

          return empty_fn
      def __enter__(		self  :						Optional[Any]):




          '''simple docstring'''


          return self



      def __exit__(		self  :						Tuple		,			lowercase_  :						Dict		,			lowercase_  :						Optional[Any]		,			lowercase_  :						int):




          '''simple docstring'''


          return




class 							lowerCAmelCase__       :






      '''simple docstring'''

      def __call__(		self  :						int		,			*lowercase_  :						Optional[Any]		,			**lowercase_  :						Dict):




          '''simple docstring'''


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




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_   :						Dict							=	None
          if _tqdm_active:
              return tqdm_lib.tqdm.set_lock(*lowercase_		,			**lowercase_)



      def _SCREAMING_SNAKE_CASE				(		self  :						Tuple):




          '''simple docstring'''


          if _tqdm_active:
              return tqdm_lib.tqdm.get_lock()



UpperCAmelCase_     :				List[Any]         =				_tqdm_cls()



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






    global _tqdm_active
    return bool(_tqdm_active							)



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






    global _tqdm_active
    SCREAMING_SNAKE_CASE_   :						int							=	True
    hf_hub_utils.enable_progress_bars()





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






    global _tqdm_active
    SCREAMING_SNAKE_CASE_   :						Any							=	False
    hf_hub_utils.disable_progress_bars()










"""simple docstring"""






# Algorithm for the pigeonhole sorting





def       _A    (__a							)				-> Dict:
    """simple docstring"""






    SCREAMING_SNAKE_CASE_   :						Dict							=	min(__a							)  # min() finds the minimum value
    SCREAMING_SNAKE_CASE_   :						int							=	max(__a							)  # max() finds the maximum value

    SCREAMING_SNAKE_CASE_   :						Dict							=	max_val - min_val + 1  # size is difference of max and min values plus one

    # list of pigeonholes of size equal to the variable size
    SCREAMING_SNAKE_CASE_   :						Any							=	[0] * size

    # Populate the pigeonholes.
    for x in a:
        assert isinstance(__a					,       __a							), "integers only please"
        holes[x - min_val] += 1

    # Putting the elements back into the array in an order.
    SCREAMING_SNAKE_CASE_   :						Any							=	0
    for count in range(__a							):
        while holes[count] > 0:
            holes[count] -= 1
            SCREAMING_SNAKE_CASE_   :						Dict							=	count + min_val
            i += 1



def       _A    ()				-> Optional[int]:
    """simple docstring"""






    SCREAMING_SNAKE_CASE_   :						List[str]							=	[8, 3, 2, 7, 4, 6, 8]
    pigeonhole_sort(__a							)
    print('''Sorted order is:'''					,       ''' '''.join(__a							)							)


if __name__ == "__main__":
  main()


