



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_									=							threading.Lock()
UpperCAmelCase_									=							None

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

UpperCAmelCase_									=							logging.WARNING

UpperCAmelCase_									=							True
def 							UpperCAmelCase__		(				)->str:
      _lowerCAmelCase 			=  os.getenv('''TRANSFORMERS_VERBOSITY'''     ,				_SCREAMING_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 							UpperCAmelCase__		(				)->str:
      return __name__.split('''.'''				)[0]
def 							UpperCAmelCase__		(				)->logging.Logger:
      return logging.getLogger(_get_library_name()				)
def 							UpperCAmelCase__		(				)->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 							UpperCAmelCase__		(				)->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 							UpperCAmelCase__		(				)->Optional[Any]:
      return log_levels
def 							UpperCAmelCase__		(				_SCREAMING_SNAKE_CASE   :	Optional[str] = None				)->logging.Logger:

      if name is None:
            _lowerCAmelCase 			=  _get_library_name()

      _configure_library_root_logger()
      return logging.getLogger(_SCREAMING_SNAKE_CASE				)
def 							UpperCAmelCase__		(				)->int:
      _configure_library_root_logger()
      return _get_library_root_logger().getEffectiveLevel()
def 							UpperCAmelCase__		(				_SCREAMING_SNAKE_CASE   :	int				)->None:
      _configure_library_root_logger()
      _get_library_root_logger().setLevel(_SCREAMING_SNAKE_CASE				)
def 							UpperCAmelCase__		(				)->Optional[int]:
      return set_verbosity(_SCREAMING_SNAKE_CASE				)
def 							UpperCAmelCase__		(				)->Union[str, Any]:
      return set_verbosity(_SCREAMING_SNAKE_CASE				)
def 							UpperCAmelCase__		(				)->Dict:
      return set_verbosity(_SCREAMING_SNAKE_CASE				)
def 							UpperCAmelCase__		(				)->Optional[Any]:
      return set_verbosity(_SCREAMING_SNAKE_CASE				)
def 							UpperCAmelCase__		(				)->None:
      _configure_library_root_logger()

      assert _default_handler is not None
      _get_library_root_logger().removeHandler(_default_handler				)
def 							UpperCAmelCase__		(				)->None:
      _configure_library_root_logger()

      assert _default_handler is not None
      _get_library_root_logger().addHandler(_default_handler				)
def 							UpperCAmelCase__		(				_SCREAMING_SNAKE_CASE   :	logging.Handler				)->None:
      _configure_library_root_logger()

      assert handler is not None
      _get_library_root_logger().addHandler(_SCREAMING_SNAKE_CASE				)
def 							UpperCAmelCase__		(				_SCREAMING_SNAKE_CASE   :	logging.Handler				)->None:
      _configure_library_root_logger()

      assert handler is not None and handler not in _get_library_root_logger().handlers
      _get_library_root_logger().removeHandler(_SCREAMING_SNAKE_CASE				)
def 							UpperCAmelCase__		(				)->None:
      _configure_library_root_logger()
      _lowerCAmelCase 			=  False
def 							UpperCAmelCase__		(				)->None:
      _configure_library_root_logger()
      _lowerCAmelCase 			=  True
def 							UpperCAmelCase__		(				)->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(_SCREAMING_SNAKE_CASE				)
def 							UpperCAmelCase__		(				)->None:
      _lowerCAmelCase 			=  _get_library_root_logger().handlers

      for handler in handlers:
            handler.setFormatter(_SCREAMING_SNAKE_CASE				)
def 							UpperCAmelCase__		(				self   :	Any     ,				*_SCREAMING_SNAKE_CASE   :	List[str]     ,				**_SCREAMING_SNAKE_CASE   :	Union[str, Any]				)->Optional[Any]:
      _lowerCAmelCase 			=  os.getenv('''TRANSFORMERS_NO_ADVISORY_WARNINGS'''     ,				_SCREAMING_SNAKE_CASE				)
      if no_advisory_warnings:
            return
      self.warning(*_SCREAMING_SNAKE_CASE     ,				**_SCREAMING_SNAKE_CASE				)


UpperCAmelCase_									=							warning_advice
@functools.lru_cache(_SCREAMING_SNAKE_CASE				)
def 							UpperCAmelCase__		(				self   :	List[Any]     ,				*_SCREAMING_SNAKE_CASE   :	List[str]     ,				**_SCREAMING_SNAKE_CASE   :	Optional[int]				)->Dict:
      self.warning(*_SCREAMING_SNAKE_CASE     ,				**_SCREAMING_SNAKE_CASE				)


UpperCAmelCase_									=							warning_once





class 		UpperCAmelCase						:





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





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





   def __getattr__(	self       ,     _lowerCAmelCase			):

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

         return empty_fn





   def __enter__(	self			):
         return self





   def __exit__(	self       ,     _lowerCAmelCase       ,     _lowerCAmelCase       ,     _lowerCAmelCase			):
         return






class 		UpperCAmelCase						:





   def __call__(	self       ,     *_lowerCAmelCase       ,     **_lowerCAmelCase			):
         if _tqdm_active:
               return tqdm_lib.tqdm(*_lowerCAmelCase       ,     **_lowerCAmelCase			)
         else:
               return EmptyTqdm(*_lowerCAmelCase       ,     **_lowerCAmelCase			)





   def 	__lowerCAmelCase							(	self       ,     *_lowerCAmelCase       ,     **_lowerCAmelCase			):
         _lowerCAmelCase 			=  None
         if _tqdm_active:
               return tqdm_lib.tqdm.set_lock(*_lowerCAmelCase       ,     **_lowerCAmelCase			)





   def 	__lowerCAmelCase							(	self			):
         if _tqdm_active:
               return tqdm_lib.tqdm.get_lock()






UpperCAmelCase_									=							_tqdm_cls()
def 							UpperCAmelCase__		(				)->bool:
      global _tqdm_active
      return bool(_tqdm_active				)
def 							UpperCAmelCase__		(				)->List[Any]:
      global _tqdm_active
      _lowerCAmelCase 			=  True
      hf_hub_utils.enable_progress_bars()


def 							UpperCAmelCase__		(				)->Optional[int]:
      global _tqdm_active
      _lowerCAmelCase 			=  False
      hf_hub_utils.disable_progress_bars()







from __future__ import annotations
def 							UpperCAmelCase__		(				_SCREAMING_SNAKE_CASE   :	list				)->list:
      if len(_SCREAMING_SNAKE_CASE				) == 0:
            return []
      _lowerCAmelCase			,   _lowerCAmelCase 			=  min(_SCREAMING_SNAKE_CASE				), max(_SCREAMING_SNAKE_CASE				)
      _lowerCAmelCase 			=  int(max_value - min_value				) + 1
      _lowerCAmelCase 			=  [[] for _ in range(_SCREAMING_SNAKE_CASE				)]

      for i in my_list:
            buckets[int(i - min_value				)].append(_SCREAMING_SNAKE_CASE				)

      return [v for bucket in buckets for v in sorted(_SCREAMING_SNAKE_CASE				)]


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

    testmod()
    assert bucket_sort([4, 5, 3, 2, 1]) == [1, 2, 3, 4, 5]
    assert bucket_sort([0, 1, -1_0, 1_5, 2, -2]) == [-1_0, -2, 0, 1, 2, 1_5]