

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


a_     :    Optional[Any]     		=   threading.Lock()
a_     :    Optional[logging.Handler]     		=   None

a_     :    Optional[int]     		=   {
    "debug": logging.DEBUG,
    "info": logging.INFO,
    "warning": logging.WARNING,
    "error": logging.ERROR,
    "critical": logging.CRITICAL,
}

a_     :    Tuple     		=   logging.WARNING

a_     :    Union[str, Any]     		=   True


def 							__lowerCAmelCase     (							)		->				Union[str, Any]:
 '''simple docstring'''


 SCREAMING_SNAKE_CASE		    =      os.getenv('TRANSFORMERS_VERBOSITY'		,				_UpperCamelCase						)
 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 							__lowerCAmelCase     (							)		->				str:
 '''simple docstring'''


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


def 							__lowerCAmelCase     (							)		->				logging.Logger:
 '''simple docstring'''


 return logging.getLogger(_get_library_name()						)


def 							__lowerCAmelCase     (							)		->				None:
 '''simple docstring'''


 global _default_handler

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

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


def 							__lowerCAmelCase     (							)		->				None:
 '''simple docstring'''


 global _default_handler

 with _lock:
  if not _default_handler:
   return

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


def 							__lowerCAmelCase     (							)		->				List[Any]:
 '''simple docstring'''


 return log_levels


def 							__lowerCAmelCase     (							_UpperCamelCase		:	Optional[str] = None						)		->				logging.Logger:
 '''simple docstring'''


 if name is None:
  SCREAMING_SNAKE_CASE		    =      _get_library_name()

 _configure_library_root_logger()
 return logging.getLogger(_UpperCamelCase						)


def 							__lowerCAmelCase     (							)		->				int:
 '''simple docstring'''


 _configure_library_root_logger()
 return _get_library_root_logger().getEffectiveLevel()


def 							__lowerCAmelCase     (							_UpperCamelCase		:	int						)		->				None:
 '''simple docstring'''


 _configure_library_root_logger()
 _get_library_root_logger().setLevel(_UpperCamelCase						)


def 							__lowerCAmelCase     (							)		->				int:
 '''simple docstring'''


 return set_verbosity(_UpperCamelCase						)


def 							__lowerCAmelCase     (							)		->				Any:
 '''simple docstring'''


 return set_verbosity(_UpperCamelCase						)


def 							__lowerCAmelCase     (							)		->				Optional[Any]:
 '''simple docstring'''


 return set_verbosity(_UpperCamelCase						)


def 							__lowerCAmelCase     (							)		->				Any:
 '''simple docstring'''


 return set_verbosity(_UpperCamelCase						)


def 							__lowerCAmelCase     (							)		->				None:
 '''simple docstring'''


 _configure_library_root_logger()

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


def 							__lowerCAmelCase     (							)		->				None:
 '''simple docstring'''


 _configure_library_root_logger()

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


def 							__lowerCAmelCase     (							_UpperCamelCase		:	logging.Handler						)		->				None:
 '''simple docstring'''


 _configure_library_root_logger()

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


def 							__lowerCAmelCase     (							_UpperCamelCase		:	logging.Handler						)		->				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(_UpperCamelCase						)


def 							__lowerCAmelCase     (							)		->				None:
 '''simple docstring'''


 _configure_library_root_logger()
 SCREAMING_SNAKE_CASE		    =      False


def 							__lowerCAmelCase     (							)		->				None:
 '''simple docstring'''


 _configure_library_root_logger()
 SCREAMING_SNAKE_CASE		    =      True


def 							__lowerCAmelCase     (							)		->				None:
 '''simple docstring'''


 SCREAMING_SNAKE_CASE		    =      _get_library_root_logger().handlers

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


def 							__lowerCAmelCase     (							)		->				None:
 '''simple docstring'''


 SCREAMING_SNAKE_CASE		    =      _get_library_root_logger().handlers

 for handler in handlers:
  handler.setFormatter(_UpperCamelCase						)


def 							__lowerCAmelCase     (							self		:	int		,				*_UpperCamelCase		:	Any		,				**_UpperCamelCase		:	List[Any]						)		->				Optional[Any]:
 '''simple docstring'''


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


a_     :    Union[str, Any]     		=   warning_advice


@functools.lru_cache(_UpperCamelCase						)
def 							__lowerCAmelCase     (							self		:	Union[str, Any]		,				*_UpperCamelCase		:	List[str]		,				**_UpperCamelCase		:	List[str]						)		->				Union[str, Any]:
 '''simple docstring'''


 self.warning(*_UpperCamelCase		,				**_UpperCamelCase						)


a_     :    Tuple     		=   warning_once




class   UpperCamelCase			:

    def __init__(      self			:   Optional[int]				,     *snake_case__			:   List[Any]				,     **snake_case__			:   Any     ):  # pylint: disable=unused-argument

     """simple docstring"""






     SCREAMING_SNAKE_CASE		    =      args[0] if args else None

    def __iter__(      self			:   Any     ):

     """simple docstring"""






     return iter(self._iterator     )

    def __getattr__(      self			:   List[str]				,     snake_case__			:   List[Any]     ):

     """simple docstring"""






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

     return empty_fn

    def __enter__(      self			:   List[Any]     ):

     """simple docstring"""






     return self




    def __exit__(      self			:   int				,     snake_case__			:   str				,     snake_case__			:   List[Any]				,     snake_case__			:   str     ):

     """simple docstring"""






     return




class   UpperCamelCase			:

    def __call__(      self			:   Dict				,     *snake_case__			:   Union[str, Any]				,     **snake_case__			:   Dict     ):

     """simple docstring"""






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

    def UpperCamelCase      (      self			:   List[Any]				,     *snake_case__			:   List[str]				,     **snake_case__			:   List[str]     ):

     """simple docstring"""






     SCREAMING_SNAKE_CASE		    =      None
     if _tqdm_active:
      return tqdm_lib.tqdm.set_lock(*snake_case__				,     **snake_case__     )




    def UpperCamelCase      (      self			:   Tuple     ):

     """simple docstring"""






     if _tqdm_active:
      return tqdm_lib.tqdm.get_lock()


a_     :    Tuple     		=   _tqdm_cls()


def 							__lowerCAmelCase     (							)		->				bool:
 '''simple docstring'''


 global _tqdm_active
 return bool(_tqdm_active						)


def 							__lowerCAmelCase     (							)		->				Dict:
 '''simple docstring'''


 global _tqdm_active
 SCREAMING_SNAKE_CASE		    =      True
 hf_hub_utils.enable_progress_bars()




def 							__lowerCAmelCase     (							)		->				Any:
 '''simple docstring'''


 global _tqdm_active
 SCREAMING_SNAKE_CASE		    =      False
 hf_hub_utils.disable_progress_bars()




import string


def 							__lowerCAmelCase     (							_UpperCamelCase		:	str						)		->				str:
 '''simple docstring'''


 SCREAMING_SNAKE_CASE		    =      ''
 for i in sequence:
  SCREAMING_SNAKE_CASE		    =      ord(_UpperCamelCase						)
  if 65 <= extract <= 90:
   output += chr(1_55 - extract						)
  elif 97 <= extract <= 1_22:
   output += chr(2_19 - extract						)
  else:
   output += i
 return output


def 							__lowerCAmelCase     (							_UpperCamelCase		:	str						)		->				str:
 '''simple docstring'''


 SCREAMING_SNAKE_CASE		    =      string.ascii_letters
 SCREAMING_SNAKE_CASE		    =      string.ascii_lowercase[::-1] + string.ascii_uppercase[::-1]
 return "".join(
     letters_reversed[letters.index(_UpperCamelCase						)] if c in letters else c for c in sequence						)


def 							__lowerCAmelCase     (							)		->				None:
 '''simple docstring'''


 from timeit import timeit

 print('Running performance benchmarks...'						)
 SCREAMING_SNAKE_CASE		    =      'from string import printable ; from __main__ import atbash, atbash_slow'
 print(f"""> atbash_slow(): {timeit('atbash_slow(printable)'		,				setup=_UpperCamelCase						)} seconds"""						)
 print(f""">      atbash(): {timeit('atbash(printable)'		,				setup=_UpperCamelCase						)} seconds"""						)


if __name__ == "__main__":
      for example in ("ABCDEFGH", "123GGjj", "testStringtest", "with space"):
            print(F"""{example} encrypted in atbash: {atbash(example)}""")
      benchmark()

