






"""simple docstring"""




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


lowerCamelCase__			=   threading.Lock()
lowerCamelCase__			=   None

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

lowerCamelCase__			=   logging.WARNING

lowerCamelCase__			=   True






def 						_SCREAMING_SNAKE_CASE							( ):
  A__											=							os.getenv("""DIFFUSERS_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 DIFFUSERS_VERBOSITY={env_level_str}, """
          F"""has to be one of: { ", ".join(log_levels.keys()    ) }"""    )
  return _default_log_level






def 						_SCREAMING_SNAKE_CASE							( ):
  return __name__.split("""."""    )[0]






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






def 						_SCREAMING_SNAKE_CASE							( ):
  global _default_handler

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

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






def 						_SCREAMING_SNAKE_CASE							( ):
  global _default_handler

  with _lock:
    if not _default_handler:
      return

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






def 						_SCREAMING_SNAKE_CASE							( ):
  return log_levels






def 						_SCREAMING_SNAKE_CASE							( UpperCamelCase     :	Union[str, Any] = None    ):






  if name is None:
    A__											=							_get_library_name()

  _configure_library_root_logger()
  return logging.getLogger(UpperCamelCase_    )






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






def 						_SCREAMING_SNAKE_CASE							( UpperCamelCase     :	Dict    ):
  _configure_library_root_logger()
  _get_library_root_logger().setLevel(UpperCamelCase_    )






def 						_SCREAMING_SNAKE_CASE							( ):
  return set_verbosity(UpperCamelCase_    )






def 						_SCREAMING_SNAKE_CASE							( ):
  return set_verbosity(UpperCamelCase_    )






def 						_SCREAMING_SNAKE_CASE							( ):
  return set_verbosity(UpperCamelCase_    )






def 						_SCREAMING_SNAKE_CASE							( ):
  return set_verbosity(UpperCamelCase_    )






def 						_SCREAMING_SNAKE_CASE							( ):
  _configure_library_root_logger()

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






def 						_SCREAMING_SNAKE_CASE							( ):
  _configure_library_root_logger()

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






def 						_SCREAMING_SNAKE_CASE							( UpperCamelCase     :	Optional[Any]    ):
  _configure_library_root_logger()

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






def 						_SCREAMING_SNAKE_CASE							( UpperCamelCase     :	Optional[Any]    ):
  _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 						_SCREAMING_SNAKE_CASE							( ):
  _configure_library_root_logger()
  A__											=							False






def 						_SCREAMING_SNAKE_CASE							( ):
  _configure_library_root_logger()
  A__											=							True






def 						_SCREAMING_SNAKE_CASE							( ):
  A__											=							_get_library_root_logger().handlers

  for handler in handlers:
    A__											=							logging.Formatter("""[%(levelname)s|%(filename)s:%(lineno)s] %(asctime)s >> %(message)s"""    )
    handler.setFormatter(UpperCamelCase_    )






def 						_SCREAMING_SNAKE_CASE							( ):
  A__											=							_get_library_root_logger().handlers

  for handler in handlers:
    handler.setFormatter(UpperCamelCase_    )






def 						_SCREAMING_SNAKE_CASE							( self     :	Dict		,				*UpperCamelCase     :	Tuple		,				**UpperCamelCase     :	Union[str, Any]    ):
  A__											=							os.getenv("""DIFFUSERS_NO_ADVISORY_WARNINGS"""		,				UpperCamelCase_    )
  if no_advisory_warnings:
    return
  self.warning(*UpperCamelCase_		,				**UpperCamelCase_    )


lowerCamelCase__			=   warning_advice







class 					_UpperCamelCase		:






    def __init__(self						,      *lowerCamelCase__						,      **lowerCamelCase__   ):  # pylint: disable=unused-argument


      """simple docstring"""
      A__											=							args[0] if args else None






    def __iter__(self   ):


      """simple docstring"""
      return iter(self._iterator   )






    def __getattr__(self						,      lowerCamelCase__   ):


      """simple docstring"""

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

      return empty_fn






    def __enter__(self   ):


      """simple docstring"""
      return self






    def __exit__(self						,      lowerCamelCase__						,      lowerCamelCase__						,      lowerCamelCase__   ):


      """simple docstring"""
      return







class 					_UpperCamelCase		:






    def __call__(self						,      *lowerCamelCase__						,      **lowerCamelCase__   ):


      """simple docstring"""
      if _tqdm_active:
        return tqdm_lib.tqdm(*__snake_case						,      **__snake_case   )
      else:
        return EmptyTqdm(*__snake_case						,      **__snake_case   )






    def  A    (self						,      *lowerCamelCase__						,      **lowerCamelCase__   ):


      """simple docstring"""
      A__											=							None
      if _tqdm_active:
        return tqdm_lib.tqdm.set_lock(*__snake_case						,      **__snake_case   )






    def  A    (self   ):


      """simple docstring"""
      if _tqdm_active:
        return tqdm_lib.tqdm.get_lock()
lowerCamelCase__			=   _tqdm_cls()






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






def 						_SCREAMING_SNAKE_CASE							( ):
  global _tqdm_active
  A__											=							True






def 						_SCREAMING_SNAKE_CASE							( ):
  global _tqdm_active
  A__											=							False












"""simple docstring"""




from .hash_table import HashTable
from .number_theory.prime_numbers import is_prime, next_prime







class 					_UpperCamelCase		( __snake_case):






    def __init__(self						,      *lowerCamelCase__						,      **lowerCamelCase__   ):


      """simple docstring"""
      super().__init__(*lowerCamelCase__						,      **lowerCamelCase__   )






    def  A    (self						,      lowerCamelCase__						,      lowerCamelCase__   ):


      """simple docstring"""
      A__											=							(
          next_prime(value % self.size_table   )
          if not is_prime(value % self.size_table   )
          else value % self.size_table
      )  # gt = bigger than
      return next_prime_gt - (data % next_prime_gt)






    def  A    (self						,      lowerCamelCase__						,      lowerCamelCase__						,      lowerCamelCase__   ):


      """simple docstring"""
      return (increment * self.__hash_function_a(lowerCamelCase__						,      lowerCamelCase__   )) % self.size_table






    def  A    (self						,      lowerCamelCase__						,      lowerCamelCase__=None   ):


      """simple docstring"""
      A__											=							1
      A__											=							self.hash_function(lowerCamelCase__   )

      while self.values[new_key] is not None and self.values[new_key] != key:
        A__											=							(
            self.__hash_double_function(lowerCamelCase__						,      lowerCamelCase__						,      lowerCamelCase__   )
            if self.balanced_factor() >= self.lim_charge
            else None
        )
        if new_key is None:
          break
        else:
          i += 1

      return new_key




