





from __future__ import annotations

import unittest

from transformers import is_tf_available, is_torch_available
from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, SMALL_MODEL_IDENTIFIER, is_pt_tf_cross_test, slow


if is_tf_available():
					from transformers import (
					    AutoConfig,
					    BertConfig,
					    GPTaConfig,
					    TaConfig,
					    TFAutoModel,
					    TFAutoModelForCausalLM,
					    TFAutoModelForMaskedLM,
					    TFAutoModelForPreTraining,
					    TFAutoModelForQuestionAnswering,
					    TFAutoModelForSeqaSeqLM,
					    TFAutoModelForSequenceClassification,
					    TFAutoModelWithLMHead,
					    TFBertForMaskedLM,
					    TFBertForPreTraining,
					    TFBertForQuestionAnswering,
					    TFBertForSequenceClassification,
					    TFBertModel,
					    TFGPTaLMHeadModel,
					    TFRobertaForMaskedLM,
					    TFTaForConditionalGeneration,
					)
					from transformers.models.bert.modeling_tf_bert import TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST
					from transformers.models.gpta.modeling_tf_gpta import TF_GPT2_PRETRAINED_MODEL_ARCHIVE_LIST
					from transformers.models.ta.modeling_tf_ta import TF_T5_PRETRAINED_MODEL_ARCHIVE_LIST

if is_torch_available():
					from transformers import (
					    AutoModel,
					    AutoModelForCausalLM,
					    AutoModelForMaskedLM,
					    AutoModelForPreTraining,
					    AutoModelForQuestionAnswering,
					    AutoModelForSeqaSeqLM,
					    AutoModelForSequenceClassification,
					    AutoModelWithLMHead,
					    BertForMaskedLM,
					    BertForPreTraining,
					    BertForQuestionAnswering,
					    BertForSequenceClassification,
					    BertModel,
					    GPTaLMHeadModel,
					    RobertaForMaskedLM,
					    TaForConditionalGeneration,
					)

@is_pt_tf_cross_test
class 							__SCREAMING_SNAKE_CASE       (  unittest.TestCase							):






							@slow
							def 					_lowerCamelCase		(    self	):
														# for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
														for model_name in ["bert-base-uncased"]:
																					UpperCamelCase__					  =      AutoConfig.from_pretrained(__lowerCAmelCase	)
																					self.assertIsNotNone(__lowerCAmelCase	)
																					self.assertIsInstance(__lowerCAmelCase	,			__lowerCAmelCase	)

																					UpperCamelCase__					  =      TFAutoModel.from_pretrained(__lowerCAmelCase	,			from_pt=__lowerCAmelCase	)
																					self.assertIsNotNone(__lowerCAmelCase	)
																					self.assertIsInstance(__lowerCAmelCase	,			__lowerCAmelCase	)

																					UpperCamelCase__					  =      AutoModel.from_pretrained(__lowerCAmelCase	,			from_tf=__lowerCAmelCase	)
																					self.assertIsNotNone(__lowerCAmelCase	)
																					self.assertIsInstance(__lowerCAmelCase	,			__lowerCAmelCase	)






							@slow
							def 					_lowerCamelCase		(    self	):
														# for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
														for model_name in ["bert-base-uncased"]:
																					UpperCamelCase__					  =      AutoConfig.from_pretrained(__lowerCAmelCase	)
																					self.assertIsNotNone(__lowerCAmelCase	)
																					self.assertIsInstance(__lowerCAmelCase	,			__lowerCAmelCase	)

																					UpperCamelCase__					  =      TFAutoModelForPreTraining.from_pretrained(__lowerCAmelCase	,			from_pt=__lowerCAmelCase	)
																					self.assertIsNotNone(__lowerCAmelCase	)
																					self.assertIsInstance(__lowerCAmelCase	,			__lowerCAmelCase	)

																					UpperCamelCase__					  =      AutoModelForPreTraining.from_pretrained(__lowerCAmelCase	,			from_tf=__lowerCAmelCase	)
																					self.assertIsNotNone(__lowerCAmelCase	)
																					self.assertIsInstance(__lowerCAmelCase	,			__lowerCAmelCase	)






							@slow
							def 					_lowerCamelCase		(    self	):
														for model_name in TF_GPT2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																					UpperCamelCase__					  =      AutoConfig.from_pretrained(__lowerCAmelCase	)
																					self.assertIsNotNone(__lowerCAmelCase	)
																					self.assertIsInstance(__lowerCAmelCase	,			__lowerCAmelCase	)

																					UpperCamelCase__					  =      TFAutoModelForCausalLM.from_pretrained(__lowerCAmelCase	,			from_pt=__lowerCAmelCase	)
																					UpperCamelCase__  ,  UpperCamelCase__					  =      TFAutoModelForCausalLM.from_pretrained(
																					    __lowerCAmelCase	,			output_loading_info=__lowerCAmelCase	,			from_pt=__lowerCAmelCase	)
																					self.assertIsNotNone(__lowerCAmelCase	)
																					self.assertIsInstance(__lowerCAmelCase	,			__lowerCAmelCase	)

																					UpperCamelCase__					  =      AutoModelForCausalLM.from_pretrained(__lowerCAmelCase	,			from_tf=__lowerCAmelCase	)
																					UpperCamelCase__  ,  UpperCamelCase__					  =      AutoModelForCausalLM.from_pretrained(
																					    __lowerCAmelCase	,			output_loading_info=__lowerCAmelCase	,			from_tf=__lowerCAmelCase	)
																					self.assertIsNotNone(__lowerCAmelCase	)
																					self.assertIsInstance(__lowerCAmelCase	,			__lowerCAmelCase	)






							@slow
							def 					_lowerCamelCase		(    self	):
														for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																					UpperCamelCase__					  =      AutoConfig.from_pretrained(__lowerCAmelCase	)
																					self.assertIsNotNone(__lowerCAmelCase	)
																					self.assertIsInstance(__lowerCAmelCase	,			__lowerCAmelCase	)

																					UpperCamelCase__					  =      TFAutoModelWithLMHead.from_pretrained(__lowerCAmelCase	,			from_pt=__lowerCAmelCase	)
																					self.assertIsNotNone(__lowerCAmelCase	)
																					self.assertIsInstance(__lowerCAmelCase	,			__lowerCAmelCase	)

																					UpperCamelCase__					  =      AutoModelWithLMHead.from_pretrained(__lowerCAmelCase	,			from_tf=__lowerCAmelCase	)
																					self.assertIsNotNone(__lowerCAmelCase	)
																					self.assertIsInstance(__lowerCAmelCase	,			__lowerCAmelCase	)






							@slow
							def 					_lowerCamelCase		(    self	):
														for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																					UpperCamelCase__					  =      AutoConfig.from_pretrained(__lowerCAmelCase	)
																					self.assertIsNotNone(__lowerCAmelCase	)
																					self.assertIsInstance(__lowerCAmelCase	,			__lowerCAmelCase	)

																					UpperCamelCase__					  =      TFAutoModelForMaskedLM.from_pretrained(__lowerCAmelCase	,			from_pt=__lowerCAmelCase	)
																					UpperCamelCase__  ,  UpperCamelCase__					  =      TFAutoModelForMaskedLM.from_pretrained(
																					    __lowerCAmelCase	,			output_loading_info=__lowerCAmelCase	,			from_pt=__lowerCAmelCase	)
																					self.assertIsNotNone(__lowerCAmelCase	)
																					self.assertIsInstance(__lowerCAmelCase	,			__lowerCAmelCase	)

																					UpperCamelCase__					  =      AutoModelForMaskedLM.from_pretrained(__lowerCAmelCase	,			from_tf=__lowerCAmelCase	)
																					UpperCamelCase__  ,  UpperCamelCase__					  =      AutoModelForMaskedLM.from_pretrained(
																					    __lowerCAmelCase	,			output_loading_info=__lowerCAmelCase	,			from_tf=__lowerCAmelCase	)
																					self.assertIsNotNone(__lowerCAmelCase	)
																					self.assertIsInstance(__lowerCAmelCase	,			__lowerCAmelCase	)






							@slow
							def 					_lowerCamelCase		(    self	):
														for model_name in TF_T5_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																					UpperCamelCase__					  =      AutoConfig.from_pretrained(__lowerCAmelCase	)
																					self.assertIsNotNone(__lowerCAmelCase	)
																					self.assertIsInstance(__lowerCAmelCase	,			__lowerCAmelCase	)

																					UpperCamelCase__					  =      TFAutoModelForSeqaSeqLM.from_pretrained(__lowerCAmelCase	,			from_pt=__lowerCAmelCase	)
																					UpperCamelCase__  ,  UpperCamelCase__					  =      TFAutoModelForSeqaSeqLM.from_pretrained(
																					    __lowerCAmelCase	,			output_loading_info=__lowerCAmelCase	,			from_pt=__lowerCAmelCase	)
																					self.assertIsNotNone(__lowerCAmelCase	)
																					self.assertIsInstance(__lowerCAmelCase	,			__lowerCAmelCase	)

																					UpperCamelCase__					  =      AutoModelForSeqaSeqLM.from_pretrained(__lowerCAmelCase	,			from_tf=__lowerCAmelCase	)
																					UpperCamelCase__  ,  UpperCamelCase__					  =      AutoModelForSeqaSeqLM.from_pretrained(
																					    __lowerCAmelCase	,			output_loading_info=__lowerCAmelCase	,			from_tf=__lowerCAmelCase	)
																					self.assertIsNotNone(__lowerCAmelCase	)
																					self.assertIsInstance(__lowerCAmelCase	,			__lowerCAmelCase	)






							@slow
							def 					_lowerCamelCase		(    self	):
														# for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
														for model_name in ["bert-base-uncased"]:
																					UpperCamelCase__					  =      AutoConfig.from_pretrained(__lowerCAmelCase	)
																					self.assertIsNotNone(__lowerCAmelCase	)
																					self.assertIsInstance(__lowerCAmelCase	,			__lowerCAmelCase	)

																					UpperCamelCase__					  =      TFAutoModelForSequenceClassification.from_pretrained(__lowerCAmelCase	,			from_pt=__lowerCAmelCase	)
																					self.assertIsNotNone(__lowerCAmelCase	)
																					self.assertIsInstance(__lowerCAmelCase	,			__lowerCAmelCase	)

																					UpperCamelCase__					  =      AutoModelForSequenceClassification.from_pretrained(__lowerCAmelCase	,			from_tf=__lowerCAmelCase	)
																					self.assertIsNotNone(__lowerCAmelCase	)
																					self.assertIsInstance(__lowerCAmelCase	,			__lowerCAmelCase	)






							@slow
							def 					_lowerCamelCase		(    self	):
														# for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
														for model_name in ["bert-base-uncased"]:
																					UpperCamelCase__					  =      AutoConfig.from_pretrained(__lowerCAmelCase	)
																					self.assertIsNotNone(__lowerCAmelCase	)
																					self.assertIsInstance(__lowerCAmelCase	,			__lowerCAmelCase	)

																					UpperCamelCase__					  =      TFAutoModelForQuestionAnswering.from_pretrained(__lowerCAmelCase	,			from_pt=__lowerCAmelCase	)
																					self.assertIsNotNone(__lowerCAmelCase	)
																					self.assertIsInstance(__lowerCAmelCase	,			__lowerCAmelCase	)

																					UpperCamelCase__					  =      AutoModelForQuestionAnswering.from_pretrained(__lowerCAmelCase	,			from_tf=__lowerCAmelCase	)
																					self.assertIsNotNone(__lowerCAmelCase	)
																					self.assertIsInstance(__lowerCAmelCase	,			__lowerCAmelCase	)






							def 					_lowerCamelCase		(    self	):
														UpperCamelCase__					  =      TFAutoModelWithLMHead.from_pretrained(__lowerCAmelCase	,			from_pt=__lowerCAmelCase	)
														self.assertIsInstance(__lowerCAmelCase	,			__lowerCAmelCase	)
														self.assertEqual(model.num_parameters()	,			14410	)
														self.assertEqual(model.num_parameters(only_trainable=__lowerCAmelCase	)	,			14410	)

														UpperCamelCase__					  =      AutoModelWithLMHead.from_pretrained(__lowerCAmelCase	,			from_tf=__lowerCAmelCase	)
														self.assertIsInstance(__lowerCAmelCase	,			__lowerCAmelCase	)
														self.assertEqual(model.num_parameters()	,			14410	)
														self.assertEqual(model.num_parameters(only_trainable=__lowerCAmelCase	)	,			14410	)







							def 					_lowerCamelCase		(    self	):
														UpperCamelCase__					  =      TFAutoModelWithLMHead.from_pretrained(__lowerCAmelCase	,			from_pt=__lowerCAmelCase	)
														self.assertIsInstance(__lowerCAmelCase	,			__lowerCAmelCase	)
														self.assertEqual(model.num_parameters()	,			14410	)
														self.assertEqual(model.num_parameters(only_trainable=__lowerCAmelCase	)	,			14410	)

														UpperCamelCase__					  =      AutoModelWithLMHead.from_pretrained(__lowerCAmelCase	,			from_tf=__lowerCAmelCase	)
														self.assertIsInstance(__lowerCAmelCase	,			__lowerCAmelCase	)
														self.assertEqual(model.num_parameters()	,			14410	)
														self.assertEqual(model.num_parameters(only_trainable=__lowerCAmelCase	)	,			14410	)











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




