
"""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


snake_case    =		threading.Lock()
snake_case    =		None

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

snake_case    =		logging.WARNING

snake_case    =		True

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

def   UpperCamelCase_  (		):
					return __name__.split('.'			)[0]

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

def   UpperCamelCase_  (		):
					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   UpperCamelCase_  (		):
					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   UpperCamelCase_  (		):
					return log_levels

def   UpperCamelCase_  (		SCREAMING_SNAKE_CASE_ = None			):

					if name is None:
										SCREAMING_SNAKE_CASE				=	_get_library_name()

					_configure_library_root_logger()
					return logging.getLogger(SCREAMING_SNAKE_CASE_			)

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

def   UpperCamelCase_  (		SCREAMING_SNAKE_CASE_			):
					_configure_library_root_logger()
					_get_library_root_logger().setLevel(SCREAMING_SNAKE_CASE_			)

def   UpperCamelCase_  (		):
					return set_verbosity(SCREAMING_SNAKE_CASE_			)

def   UpperCamelCase_  (		):
					return set_verbosity(SCREAMING_SNAKE_CASE_			)

def   UpperCamelCase_  (		):
					return set_verbosity(SCREAMING_SNAKE_CASE_			)

def   UpperCamelCase_  (		):
					return set_verbosity(SCREAMING_SNAKE_CASE_			)

def   UpperCamelCase_  (		):
					_configure_library_root_logger()

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

def   UpperCamelCase_  (		):
					_configure_library_root_logger()

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

def   UpperCamelCase_  (		SCREAMING_SNAKE_CASE_			):
					_configure_library_root_logger()

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

def   UpperCamelCase_  (		SCREAMING_SNAKE_CASE_			):
					_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_  (		):
					_configure_library_root_logger()
					SCREAMING_SNAKE_CASE				=	False

def   UpperCamelCase_  (		):
					_configure_library_root_logger()
					SCREAMING_SNAKE_CASE				=	True

def   UpperCamelCase_  (		):
					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(SCREAMING_SNAKE_CASE_			)

def   UpperCamelCase_  (		):
					SCREAMING_SNAKE_CASE				=	_get_library_root_logger().handlers

					for handler in handlers:
										handler.setFormatter(SCREAMING_SNAKE_CASE_			)

def   UpperCamelCase_  (		self,     *SCREAMING_SNAKE_CASE_,     **SCREAMING_SNAKE_CASE_			):
					SCREAMING_SNAKE_CASE				=	os.getenv('DIFFUSERS_NO_ADVISORY_WARNINGS',     SCREAMING_SNAKE_CASE_			)
					if no_advisory_warnings:
										return
					self.warning(*SCREAMING_SNAKE_CASE_,     **SCREAMING_SNAKE_CASE_			)


snake_case    =		warning_advice




class      UpperCamelCase	:

				"""simple docstring"""



				def __init__(				self		,	*lowercase__		,	**lowercase__			)    ->    Tuple:  # pylint: disable=unused-argument
									"""simple docstring"""







									SCREAMING_SNAKE_CASE				=	args[0] if args else None


				def __iter__(				self			)    ->    List[Any]:
									"""simple docstring"""







									return iter(self._iterator			)


				def __getattr__(				self		,	lowercase__			)    ->    Optional[Any]:
									"""simple docstring"""







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

									return empty_fn


				def __enter__(				self			)    ->    List[Any]:
									"""simple docstring"""







									return self




				def __exit__(				self		,	lowercase__		,	lowercase__		,	lowercase__			)    ->    Dict:
									"""simple docstring"""







									return






class      UpperCamelCase	:

				"""simple docstring"""



				def __call__(				self		,	*lowercase__		,	**lowercase__			)    ->    List[str]:
									"""simple docstring"""







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


				def 							A					(				self		,	*lowercase__		,	**lowercase__			)    ->    Any:
									"""simple docstring"""







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




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







									if _tqdm_active:
														return tqdm_lib.tqdm.get_lock()






snake_case    =		_tqdm_cls()

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

def   UpperCamelCase_  (		):
					global _tqdm_active
					SCREAMING_SNAKE_CASE				=	True



def   UpperCamelCase_  (		):
					global _tqdm_active
					SCREAMING_SNAKE_CASE				=	False


"""simple docstring"""




from functools import lru_cache

@lru_cache
def   UpperCamelCase_  (		SCREAMING_SNAKE_CASE_			):
					if not isinstance(SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_			):
										raise TypeError('k must be an integer.'			)
					if k < 0:
										raise ValueError('k integer must be greater or equal to zero.'			)
					if k == 0:
										return 0
					elif k == 1:
										return 1
					else:
										return fibonacci(k - 1			) + fibonacci(k - 2			)

def   UpperCamelCase_  (		SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_			):
					SCREAMING_SNAKE_CASE				=	len(SCREAMING_SNAKE_CASE_			)
					# Find m such that F_m >= n where F_i is the i_th fibonacci number.
					SCREAMING_SNAKE_CASE				=	0
					while True:
										if fibonacci(SCREAMING_SNAKE_CASE_			) >= len_list:
															SCREAMING_SNAKE_CASE				=	i
															break
										i += 1
					SCREAMING_SNAKE_CASE				=	0
					while fibb_k > 0:
										SCREAMING_SNAKE_CASE				=	min(
										    offset + fibonacci(fibb_k - 1			),     len_list - 1			)  # Prevent out of range
										SCREAMING_SNAKE_CASE				=	arr[index_k]
										if item_k_1 == val:
															return index_k
										elif val < item_k_1:
															fibb_k -= 1
										elif val > item_k_1:
															offset += fibonacci(fibb_k - 1			)
															fibb_k -= 2
					else:
										return -1


if __name__ == "__main__":
	import doctest

	doctest.testmod()
