

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

from tqdm import auto as tqdm_lib


_SCREAMING_SNAKE_CASE							 =			threading.Lock()
_SCREAMING_SNAKE_CASE							 =			None

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

_SCREAMING_SNAKE_CASE							 =			logging.WARNING

_SCREAMING_SNAKE_CASE							 =			True





def  _snake_case		()							->		Union[str, Any]:
  __UpperCAmelCase	:  Optional[int]		=     os.getenv('DIFFUSERS_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 DIFFUSERS_VERBOSITY={env_level_str}, "
          F"has to be one of: { ', '.join(log_levels.keys()  ) }"  )
  return _default_log_level





def  _snake_case		()							->		str:
  return __name__.split('.'  )[0]





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





def  _snake_case		()							->		None:
  global _default_handler

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

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





def  _snake_case		()							->		None:
  global _default_handler

  with _lock:
    if not _default_handler:
      return

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





def  _snake_case		()							->		Union[str, Any]:
  return log_levels





def  _snake_case		(snake_case_					:     Optional[str] = None  )							->		logging.Logger:

  if name is None:
    __UpperCAmelCase	:  str		=     _get_library_name()

  _configure_library_root_logger()
  return logging.getLogger(snake_case_  )





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





def  _snake_case		(snake_case_					:     int  )							->		None:
  _configure_library_root_logger()
  _get_library_root_logger().setLevel(snake_case_  )





def  _snake_case		()							->		str:
  return set_verbosity(snake_case_  )





def  _snake_case		()							->		Optional[Any]:
  return set_verbosity(snake_case_  )





def  _snake_case		()							->		Optional[Any]:
  return set_verbosity(snake_case_  )





def  _snake_case		()							->		List[Any]:
  return set_verbosity(snake_case_  )





def  _snake_case		()							->		None:
  _configure_library_root_logger()

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





def  _snake_case		()							->		None:
  _configure_library_root_logger()

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





def  _snake_case		(snake_case_					:     logging.Handler  )							->		None:
  _configure_library_root_logger()

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





def  _snake_case		(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(snake_case_  )





def  _snake_case		()							->		None:
  _configure_library_root_logger()
  __UpperCAmelCase	:  List[Any]		=     False





def  _snake_case		()							->		None:
  _configure_library_root_logger()
  __UpperCAmelCase	:  str		=     True





def  _snake_case		()							->		None:
  __UpperCAmelCase	:  Any		=     _get_library_root_logger().handlers

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





def  _snake_case		()							->		None:
  __UpperCAmelCase	:  Dict		=     _get_library_root_logger().handlers

  for handler in handlers:
    handler.setFormatter(snake_case_  )





def  _snake_case		(self					:     Tuple    ,       *snake_case_					:     str    ,       **snake_case_					:     Tuple  )							->		str:
  __UpperCAmelCase	:  str		=     os.getenv('DIFFUSERS_NO_ADVISORY_WARNINGS'    ,       snake_case_  )
  if no_advisory_warnings:
    return
  self.warning(*snake_case_    ,       **snake_case_  )


_SCREAMING_SNAKE_CASE							 =			warning_advice


class      lowerCamelCase_ :




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




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




 def __getattr__(			self  ,  _UpperCAmelCase							):

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

   return empty_fn




 def __enter__(			self							):
   return self




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



class      lowerCamelCase_ :




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




 def     a       (			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   __UpperCAmelCase	:  Tuple		=     None
   if _tqdm_active:
     return tqdm_lib.tqdm.set_lock(*_UpperCAmelCase  ,  **_UpperCAmelCase							)




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



_SCREAMING_SNAKE_CASE							 =			_tqdm_cls()





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





def  _snake_case		()							->		Any:
  global _tqdm_active
  __UpperCAmelCase	:  int		=     True







def  _snake_case		()							->		str:
  global _tqdm_active
  __UpperCAmelCase	:  Dict		=     False








from __future__ import annotations





def  _snake_case		(snake_case_					:     str  )							->		bool:
  __UpperCAmelCase	:  int
  __UpperCAmelCase	:  list[str]		=     list(snake_case_  )
  __UpperCAmelCase,			__UpperCAmelCase	:  Any		=     _vector[:-1], int(_vector[-1]  )
  __UpperCAmelCase	:  list[int]		=     [int(snake_case_  ) for digit in __vector]

  vector.reverse()
  for i, digit in enumerate(snake_case_  ):
    if i & 1 == 0:
      __UpperCAmelCase	:  int		=     digit * 2
      if doubled > 9:
        doubled -= 9
      check_digit += doubled
    else:
      check_digit += digit

  return check_digit % 10 == 0


if __name__ == "__main__":
      import doctest

      doctest.testmod()
      assert is_luhn('''79927398713''')
      assert not is_luhn('''79927398714''')





