



from tempfile import TemporaryDirectory
from unittest import TestCase
from unittest.mock import MagicMock, patch

from transformers import AutoModel, TFAutoModel
from transformers.onnx import FeaturesManager
from transformers.testing_utils import SMALL_MODEL_IDENTIFIER, require_tf, require_torch

@require_torch
@require_tf
class   _A   ( _lowercase	):


						'''simple docstring'''





						def     _snake_case	(	self	:							Optional[Any]	):






							'''simple docstring'''



							__lowercase		       =			SMALL_MODEL_IDENTIFIER
							__lowercase		       =			"pt"
							__lowercase		       =			"tf"



						def     _snake_case	(	self	:							Union[str, Any]							,      lowerCamelCase	:							Any	):






							'''simple docstring'''



							__lowercase		       =			AutoModel.from_pretrained(self.test_model	)
							model_pt.save_pretrained(lowerCamelCase	)



						def     _snake_case	(	self	:							int							,      lowerCamelCase	:							List[Any]	):






							'''simple docstring'''



							__lowercase		       =			TFAutoModel.from_pretrained(self.test_model							,      from_pt=lowerCamelCase	)
							model_tf.save_pretrained(lowerCamelCase	)



						def     _snake_case	(	self	:							Dict	):






							'''simple docstring'''



							__lowercase		       =			"mock_framework"

							# Framework provided - return whatever the user provides
							__lowercase		       =			FeaturesManager.determine_framework(self.test_model							,      lowerCamelCase	)
							self.assertEqual(lowerCamelCase							,      lowerCamelCase	)

							# Local checkpoint and framework provided - return provided framework
							# PyTorch checkpoint
							with TemporaryDirectory() as local_pt_ckpt:
								self._setup_pt_ckpt(lowerCamelCase	)
								__lowercase		       =			FeaturesManager.determine_framework(lowerCamelCase							,      lowerCamelCase	)
								self.assertEqual(lowerCamelCase							,      lowerCamelCase	)

							# TensorFlow checkpoint
							with TemporaryDirectory() as local_tf_ckpt:
								self._setup_tf_ckpt(lowerCamelCase	)
								__lowercase		       =			FeaturesManager.determine_framework(lowerCamelCase							,      lowerCamelCase	)
								self.assertEqual(lowerCamelCase							,      lowerCamelCase	)



						def     _snake_case	(	self	:							Dict	):






							'''simple docstring'''



							with TemporaryDirectory() as local_pt_ckpt:
								self._setup_pt_ckpt(lowerCamelCase	)
								__lowercase		       =			FeaturesManager.determine_framework(lowerCamelCase	)
								self.assertEqual(lowerCamelCase							,      self.framework_pt	)

							# TensorFlow checkpoint
							with TemporaryDirectory() as local_tf_ckpt:
								self._setup_tf_ckpt(lowerCamelCase	)
								__lowercase		       =			FeaturesManager.determine_framework(lowerCamelCase	)
								self.assertEqual(lowerCamelCase							,      self.framework_tf	)

							# Invalid local checkpoint
							with TemporaryDirectory() as local_invalid_ckpt:
								with self.assertRaises(lowerCamelCase	):
									__lowercase		       =			FeaturesManager.determine_framework(lowerCamelCase	)



						def     _snake_case	(	self	:							Any	):






							'''simple docstring'''



							__lowercase		       =			MagicMock(return_value=lowerCamelCase	)
							with patch("transformers.onnx.features.is_tf_available"							,      lowerCamelCase	):
								__lowercase		       =			FeaturesManager.determine_framework(self.test_model	)
								self.assertEqual(lowerCamelCase							,      self.framework_pt	)

							# PyTorch not in environment -> use TensorFlow
							__lowercase		       =			MagicMock(return_value=lowerCamelCase	)
							with patch("transformers.onnx.features.is_torch_available"							,      lowerCamelCase	):
								__lowercase		       =			FeaturesManager.determine_framework(self.test_model	)
								self.assertEqual(lowerCamelCase							,      self.framework_tf	)

							# Both in environment -> use PyTorch
							__lowercase		       =			MagicMock(return_value=lowerCamelCase	)
							__lowercase		       =			MagicMock(return_value=lowerCamelCase	)
							with patch("transformers.onnx.features.is_tf_available"							,      lowerCamelCase	), patch(
							    "transformers.onnx.features.is_torch_available"							,      lowerCamelCase	):
								__lowercase		       =			FeaturesManager.determine_framework(self.test_model	)
								self.assertEqual(lowerCamelCase							,      self.framework_pt	)

							# Both not in environment -> raise error
							__lowercase		       =			MagicMock(return_value=lowerCamelCase	)
							__lowercase		       =			MagicMock(return_value=lowerCamelCase	)
							with patch("transformers.onnx.features.is_tf_available"							,      lowerCamelCase	), patch(
							    "transformers.onnx.features.is_torch_available"							,      lowerCamelCase	):
								with self.assertRaises(lowerCamelCase	):
									__lowercase		       =			FeaturesManager.determine_framework(self.test_model	)








from __future__ import annotations

import bisect



def    snake_case_				(    _SCREAMING_SNAKE_CASE  ,	_SCREAMING_SNAKE_CASE  ,	_SCREAMING_SNAKE_CASE = 0  ,	_SCREAMING_SNAKE_CASE = -1   ):
	if hi < 0:
		__lowercase		       =			len(_SCREAMING_SNAKE_CASE   )

	while lo < hi:
		__lowercase		       =			lo + (hi - lo) // 2
		if sorted_collection[mid] < item:
			__lowercase		       =			mid + 1
		else:
			__lowercase		       =			mid

	return lo



def    snake_case_				(    _SCREAMING_SNAKE_CASE  ,	_SCREAMING_SNAKE_CASE  ,	_SCREAMING_SNAKE_CASE = 0  ,	_SCREAMING_SNAKE_CASE = -1   ):
	if hi < 0:
		__lowercase		       =			len(_SCREAMING_SNAKE_CASE   )

	while lo < hi:
		__lowercase		       =			lo + (hi - lo) // 2
		if sorted_collection[mid] <= item:
			__lowercase		       =			mid + 1
		else:
			__lowercase		       =			mid

	return lo



def    snake_case_				(    _SCREAMING_SNAKE_CASE  ,	_SCREAMING_SNAKE_CASE  ,	_SCREAMING_SNAKE_CASE = 0  ,	_SCREAMING_SNAKE_CASE = -1   ):
	sorted_collection.insert(bisect_left(_SCREAMING_SNAKE_CASE  ,	_SCREAMING_SNAKE_CASE  ,	_SCREAMING_SNAKE_CASE  ,	_SCREAMING_SNAKE_CASE   )  ,	_SCREAMING_SNAKE_CASE   )



def    snake_case_				(    _SCREAMING_SNAKE_CASE  ,	_SCREAMING_SNAKE_CASE  ,	_SCREAMING_SNAKE_CASE = 0  ,	_SCREAMING_SNAKE_CASE = -1   ):
	sorted_collection.insert(bisect_right(_SCREAMING_SNAKE_CASE  ,	_SCREAMING_SNAKE_CASE  ,	_SCREAMING_SNAKE_CASE  ,	_SCREAMING_SNAKE_CASE   )  ,	_SCREAMING_SNAKE_CASE   )



def    snake_case_				(    _SCREAMING_SNAKE_CASE  ,	_SCREAMING_SNAKE_CASE   ):
	__lowercase		       =			0
	__lowercase		       =			len(_SCREAMING_SNAKE_CASE   ) - 1

	while left <= right:
		__lowercase		       =			left + (right - left) // 2
		__lowercase		       =			sorted_collection[midpoint]
		if current_item == item:
			return midpoint
		elif item < current_item:
			__lowercase		       =			midpoint - 1
		else:
			__lowercase		       =			midpoint + 1
	return None



def    snake_case_				(    _SCREAMING_SNAKE_CASE  ,	_SCREAMING_SNAKE_CASE   ):
	__lowercase		       =			bisect.bisect_left(_SCREAMING_SNAKE_CASE  ,	_SCREAMING_SNAKE_CASE   )
	if index != len(_SCREAMING_SNAKE_CASE   ) and sorted_collection[index] == item:
		return index
	return None



def    snake_case_				(    _SCREAMING_SNAKE_CASE  ,	_SCREAMING_SNAKE_CASE  ,	_SCREAMING_SNAKE_CASE  ,	_SCREAMING_SNAKE_CASE   ):
	if right < left:
		return None

	__lowercase		       =			left + (right - left) // 2

	if sorted_collection[midpoint] == item:
		return midpoint
	elif sorted_collection[midpoint] > item:
		return binary_search_by_recursion(_SCREAMING_SNAKE_CASE  ,	_SCREAMING_SNAKE_CASE  ,	_SCREAMING_SNAKE_CASE  ,	midpoint - 1   )
	else:
		return binary_search_by_recursion(_SCREAMING_SNAKE_CASE  ,	_SCREAMING_SNAKE_CASE  ,	midpoint + 1  ,	_SCREAMING_SNAKE_CASE   )


if __name__ == "__main__":
	snake_case__					:     Optional[Any]    		=   input("""Enter numbers separated by comma:\n""").strip()
	snake_case__					:     Any    		=   sorted(int(item) for item in user_input.split(""","""))
	snake_case__					:     Any    		=   int(input("""Enter a single number to be found in the list:\n"""))
	snake_case__					:     List[Any]    		=   binary_search(collection, target)
	if result is None:
		print(F'''{target} was not found in {collection}.''')
	else:
		print(F'''{target} was found at position {result} in {collection}.''')



