





'''simple docstring'''

from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tensorflow_text_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


lowercase__		:     List[Any]			=							{
    'configuration_bert': ['BERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BertConfig', 'BertOnnxConfig'],
    'tokenization_bert': ['BasicTokenizer', 'BertTokenizer', 'WordpieceTokenizer'],
}

try:
   if not is_tokenizers_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   lowercase__		:     Union[str, Any]			=							['BertTokenizerFast']

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   lowercase__		:     str			=							[
       'BERT_PRETRAINED_MODEL_ARCHIVE_LIST',
       'BertForMaskedLM',
       'BertForMultipleChoice',
       'BertForNextSentencePrediction',
       'BertForPreTraining',
       'BertForQuestionAnswering',
       'BertForSequenceClassification',
       'BertForTokenClassification',
       'BertLayer',
       'BertLMHeadModel',
       'BertModel',
       'BertPreTrainedModel',
       'load_tf_weights_in_bert',
   ]

try:
   if not is_tf_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   lowercase__		:     Optional[int]			=							[
       'TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST',
       'TFBertEmbeddings',
       'TFBertForMaskedLM',
       'TFBertForMultipleChoice',
       'TFBertForNextSentencePrediction',
       'TFBertForPreTraining',
       'TFBertForQuestionAnswering',
       'TFBertForSequenceClassification',
       'TFBertForTokenClassification',
       'TFBertLMHeadModel',
       'TFBertMainLayer',
       'TFBertModel',
       'TFBertPreTrainedModel',
   ]
try:
   if not is_tensorflow_text_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   lowercase__		:     Tuple			=							['TFBertTokenizer']

try:
   if not is_flax_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   lowercase__		:     Union[str, Any]			=							[
       'FlaxBertForCausalLM',
       'FlaxBertForMaskedLM',
       'FlaxBertForMultipleChoice',
       'FlaxBertForNextSentencePrediction',
       'FlaxBertForPreTraining',
       'FlaxBertForQuestionAnswering',
       'FlaxBertForSequenceClassification',
       'FlaxBertForTokenClassification',
       'FlaxBertModel',
       'FlaxBertPreTrainedModel',
   ]

if TYPE_CHECKING:
   from .configuration_bert import BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, BertConfig, BertOnnxConfig
   from .tokenization_bert import BasicTokenizer, BertTokenizer, WordpieceTokenizer

   try:
      if not is_tokenizers_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .tokenization_bert_fast import BertTokenizerFast

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_bert import (
          BERT_PRETRAINED_MODEL_ARCHIVE_LIST,
          BertForMaskedLM,
          BertForMultipleChoice,
          BertForNextSentencePrediction,
          BertForPreTraining,
          BertForQuestionAnswering,
          BertForSequenceClassification,
          BertForTokenClassification,
          BertLayer,
          BertLMHeadModel,
          BertModel,
          BertPreTrainedModel,
          load_tf_weights_in_bert,
      )

   try:
      if not is_tf_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_tf_bert import (
          TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST,
          TFBertEmbeddings,
          TFBertForMaskedLM,
          TFBertForMultipleChoice,
          TFBertForNextSentencePrediction,
          TFBertForPreTraining,
          TFBertForQuestionAnswering,
          TFBertForSequenceClassification,
          TFBertForTokenClassification,
          TFBertLMHeadModel,
          TFBertMainLayer,
          TFBertModel,
          TFBertPreTrainedModel,
      )

   try:
      if not is_tensorflow_text_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .tokenization_bert_tf import TFBertTokenizer

   try:
      if not is_flax_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_flax_bert import (
          FlaxBertForCausalLM,
          FlaxBertForMaskedLM,
          FlaxBertForMultipleChoice,
          FlaxBertForNextSentencePrediction,
          FlaxBertForPreTraining,
          FlaxBertForQuestionAnswering,
          FlaxBertForSequenceClassification,
          FlaxBertForTokenClassification,
          FlaxBertModel,
          FlaxBertPreTrainedModel,
      )

else:
   import sys

   lowercase__		:     Dict			=							_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)










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.
UpperCamelCase__           =			10





def      _UpperCamelCase  (a__ :int ,      a__ :int ,      a__ :list[int] ,      a__ :int							):






							"""simple docstring"""





							for i in range(a__ ,      a__							):
														if array[i] == target:
																					return i
							return -1





def      _UpperCamelCase  (a__ :list[int] ,      a__ :int							):






							"""simple docstring"""





							UpperCamelCase__					  =      0
							UpperCamelCase__					  =      len(a__							)
							while left <= right:
														if right - left < precision:
																					return lin_search(a__ ,      a__ ,      a__ ,      a__							)

														UpperCamelCase__					  =      (left + right) // 3 + 1
														UpperCamelCase__					  =      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]:
																					UpperCamelCase__					  =      one_third - 1
														elif array[two_third] < target:
																					UpperCamelCase__					  =      two_third + 1

														else:
																					UpperCamelCase__					  =      one_third + 1
																					UpperCamelCase__					  =      two_third - 1
							else:
														return -1





def      _UpperCamelCase  (a__ :int ,      a__ :int ,      a__ :list[int] ,      a__ :int							):






							"""simple docstring"""





							if left < right:
														if right - left < precision:
																					return lin_search(a__ ,      a__ ,      a__ ,      a__							)
														UpperCamelCase__					  =      (left + right) // 3 + 1
														UpperCamelCase__					  =      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(a__ ,      one_third - 1 ,      a__ ,      a__							)
														elif array[two_third] < target:
																					return rec_ternary_search(two_third + 1 ,      a__ ,      a__ ,      a__							)
														else:
																					return rec_ternary_search(one_third + 1 ,      two_third - 1 ,      a__ ,      a__							)
							else:
														return -1


if __name__ == "__main__":
					import doctest

					doctest.testmod()

					UpperCamelCase__           =			input("Enter numbers separated by comma:\n").strip()
					UpperCamelCase__           =			[int(item.strip()) for item in user_input.split(",")]
					assert collection == sorted(collection), f"List must be ordered.\n{collection}."
					UpperCamelCase__           =			int(input("Enter the number to be found in the list:\n").strip())
					UpperCamelCase__           =			ite_ternary_search(collection, target)
					UpperCamelCase__           =			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")




