
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


lowercase__          =threading.Lock()
lowercase__          =None

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

lowercase__          =logging.WARNING

lowercase__          =True




def        __UpperCamelCase					(    ):
	__a			:  str		    =  os.getenv('''TRANSFORMERS_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 TRANSFORMERS_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
		__a			:  int		    =  logging.StreamHandler()  # Set sys.stderr as stream.
		__a			:  Dict		    =  sys.stderr.flush

		# Apply our default configuration to the library root logger.
		__a			:  List[Any]		    =  _get_library_root_logger()
		library_root_logger.addHandler(_default_handler  )
		library_root_logger.setLevel(_get_default_logging_level()  )
		__a			:  List[Any]		    =  False




def        __UpperCamelCase					(    ):
	global _default_handler

	with _lock:
		if not _default_handler:
			return

		__a			:  List[str]		    =  _get_library_root_logger()
		library_root_logger.removeHandler(_default_handler  )
		library_root_logger.setLevel(logging.NOTSET  )
		__a			:  Tuple		    =  None




def        __UpperCamelCase					(    ):
	return log_levels




def        __UpperCamelCase					(    lowerCAmelCase__							:    Optional[str] = None  ):

	if name is None:
		__a			:  Tuple		    =  _get_library_name()

	_configure_library_root_logger()
	return logging.getLogger(snake_case__  )




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




def        __UpperCamelCase					(    lowerCAmelCase__							:    int  ):
	_configure_library_root_logger()
	_get_library_root_logger().setLevel(snake_case__  )




def        __UpperCamelCase					(    ):
	return set_verbosity(snake_case__  )




def        __UpperCamelCase					(    ):
	return set_verbosity(snake_case__  )




def        __UpperCamelCase					(    ):
	return set_verbosity(snake_case__  )




def        __UpperCamelCase					(    ):
	return set_verbosity(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					(    lowerCAmelCase__							:    logging.Handler  ):
	_configure_library_root_logger()

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




def        __UpperCamelCase					(    lowerCAmelCase__							:    logging.Handler  ):
	_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        __UpperCamelCase					(    ):
	_configure_library_root_logger()
	__a			:  str		    =  False




def        __UpperCamelCase					(    ):
	_configure_library_root_logger()
	__a			:  Optional[Any]		    =  True




def        __UpperCamelCase					(    ):
	__a			:  Dict		    =  _get_library_root_logger().handlers

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




def        __UpperCamelCase					(    ):
	__a			:  Dict		    =  _get_library_root_logger().handlers

	for handler in handlers:
		handler.setFormatter(snake_case__  )




def        __UpperCamelCase					(    self							:    str  ,       *lowerCAmelCase__							:    Optional[Any]  ,       **lowerCAmelCase__							:    List[str]  ):
	__a			:  List[Any]		    =  os.getenv('''TRANSFORMERS_NO_ADVISORY_WARNINGS'''  ,       snake_case__  )
	if no_advisory_warnings:
		return
	self.warning(*snake_case__  ,       **snake_case__  )


lowercase__          =warning_advice




@functools.lru_cache(snake_case__  )
def        __UpperCamelCase					(    self							:    List[str]  ,       *lowerCAmelCase__							:    int  ,       **lowerCAmelCase__							:    List[Any]  ):
	self.warning(*snake_case__  ,       **snake_case__  )


lowercase__          =warning_once



class 		UpperCamelCase__  :
			def __init__(self			: int ,    *snake_case_			: Any ,    **snake_case_			: str       ):  # pylint: disable=unused-argument
				__a			:  Dict		    =  args[0] if args else None
			def __iter__(self			: str       ):
				return iter(self._iterator       )
			def __getattr__(self			: Tuple ,    snake_case_			: Optional[Any]       ):

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

				return empty_fn
			def __enter__(self			: Tuple       ):
				return self







			def __exit__(self			: Any ,    snake_case_			: Dict ,    snake_case_			: str ,    snake_case_			: Optional[Any]       ):
				return





class 		UpperCamelCase__  :
			def __call__(self			: Optional[int] ,    *snake_case_			: Tuple ,    **snake_case_			: List[Any]       ):
				if _tqdm_active:
					return tqdm_lib.tqdm(*lowerCAmelCase_ ,    **lowerCAmelCase_       )
				else:
					return EmptyTqdm(*lowerCAmelCase_ ,    **lowerCAmelCase_       )
			def 				lowerCAmelCase      (self			: Union[str, Any] ,    *snake_case_			: List[Any] ,    **snake_case_			: Any       ):
				__a			:  Dict		    =  None
				if _tqdm_active:
					return tqdm_lib.tqdm.set_lock(*lowerCAmelCase_ ,    **lowerCAmelCase_       )







			def 				lowerCAmelCase      (self			: List[str]       ):
				if _tqdm_active:
					return tqdm_lib.tqdm.get_lock()





lowercase__          =_tqdm_cls()




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




def        __UpperCamelCase					(    ):
	global _tqdm_active
	__a			:  int		    =  True
	hf_hub_utils.enable_progress_bars()




def        __UpperCamelCase					(    ):
	global _tqdm_active
	__a			:  Dict		    =  False
	hf_hub_utils.disable_progress_bars()


from __future__ import annotations

# This is the precision for this function which can be altered.
# It is recommended for users to keep this number greater than or equal to 10.
lowercase__          =10




def        __UpperCamelCase					(    lowerCAmelCase__							:    int  ,       lowerCAmelCase__							:    int  ,       lowerCAmelCase__							:    list[int]  ,       lowerCAmelCase__							:    int  ):
 for i in range(lowerCAmelCase__  ,       lowerCAmelCase__  ):
  if array[i] == target:
   return i
 return -1




def        __UpperCamelCase					(    lowerCAmelCase__							:    list[int]  ,       lowerCAmelCase__							:    int  ):
 __a			:  List[Any]		    =  0
 __a			:  Union[str, Any]		    =  len(lowerCAmelCase__  )
 while left <= right:
  if right - left < precision:
   return lin_search(lowerCAmelCase__  ,       lowerCAmelCase__  ,       lowerCAmelCase__  ,       lowerCAmelCase__  )

  __a			:  str		    =  (left + right) // 3 + 1
  __a			:  List[Any]		    =  2 * (left + right) // 3 + 1

  if array[one_third] == target:
   return one_third
  elif array[two_third] == target:
   return two_third

  elif target < array[one_third]:
   __a			:  List[str]		    =  one_third - 1
  elif array[two_third] < target:
   __a			:  List[str]		    =  two_third + 1

  else:
   __a			:  Dict		    =  one_third + 1
   __a			:  Any		    =  two_third - 1
 else:
  return -1




def        __UpperCamelCase					(    lowerCAmelCase__							:    int  ,       lowerCAmelCase__							:    int  ,       lowerCAmelCase__							:    list[int]  ,       lowerCAmelCase__							:    int  ):
 if left < right:
  if right - left < precision:
   return lin_search(lowerCAmelCase__  ,       lowerCAmelCase__  ,       lowerCAmelCase__  ,       lowerCAmelCase__  )
  __a			:  Union[str, Any]		    =  (left + right) // 3 + 1
  __a			:  Optional[Any]		    =  2 * (left + right) // 3 + 1

  if array[one_third] == target:
   return one_third
  elif array[two_third] == target:
   return two_third

  elif target < array[one_third]:
   return rec_ternary_search(lowerCAmelCase__  ,       one_third - 1  ,       lowerCAmelCase__  ,       lowerCAmelCase__  )
  elif array[two_third] < target:
   return rec_ternary_search(two_third + 1  ,       lowerCAmelCase__  ,       lowerCAmelCase__  ,       lowerCAmelCase__  )
  else:
   return rec_ternary_search(one_third + 1  ,       two_third - 1  ,       lowerCAmelCase__  ,       lowerCAmelCase__  )
 else:
  return -1


if __name__ == "__main__":
      import doctest

      doctest.testmod()

      lowercase__          =input('Enter numbers separated by comma:\n').strip()
      lowercase__          =[int(item.strip()) for item in user_input.split(',')]
      assert collection == sorted(collection), F"List must be ordered.\n{collection}."
      lowercase__          =int(input('Enter the number to be found in the list:\n').strip())
      lowercase__          =ite_ternary_search(collection, target)
      lowercase__          =rec_ternary_search(0, len(collection) - 1, collection, target)
      if resulta != -1:
            print(F"""Iterative search: {target} found at positions: {resulta}""")
            print(F"""Recursive search: {target} found at positions: {resulta}""")
      else:
            print('Not found')
