"""simple docstring"""







import shutil
import tempfile
import unittest

import numpy as np

from transformers.testing_utils import (
    is_pt_tf_cross_test,
    require_tf,
    require_torch,
    require_torchvision,
    require_vision,
)
from transformers.utils import is_tf_available, is_torch_available, is_vision_available


if is_vision_available():
	from PIL import Image

	from transformers import AutoProcessor, SamImageProcessor, SamProcessor

if is_torch_available():
	import torch

if is_tf_available():
	import tensorflow as tf

@require_vision
@require_torchvision
class 	UpperCamelCase    (					unittest.TestCase		):



				def       _lowercase  (self       :   Union[str, Any])					->			Any:
					__snake_case    :							List[str]   	=				tempfile.mkdtemp()
					__snake_case    :							List[str]   	=				SamImageProcessor()
					__snake_case    :							Union[str, Any]   	=				SamProcessor(_A)
					processor.save_pretrained(self.tmpdirname)



				def       _lowercase  (self       :   str			,						**_A       :   Any)					->			List[Any]:
					return AutoProcessor.from_pretrained(self.tmpdirname			,						**_A).image_processor



				def       _lowercase  (self       :   List[Any])					->			Any:
					shutil.rmtree(self.tmpdirname)



				def       _lowercase  (self       :   List[Any])					->			Dict:
					__snake_case    :							Optional[Any]   	=				[np.random.randint(2_55			,						size=(3, 30, 4_00)			,						dtype=np.uinta)]

					__snake_case    :							Dict   	=				[Image.fromarray(np.moveaxis(_A			,						0			,						-1)) for x in image_inputs]

					return image_inputs



				def       _lowercase  (self       :   str)					->			int:
					__snake_case    :							Dict   	=				SamProcessor(image_processor=self.get_image_processor())
					processor.save_pretrained(self.tmpdirname)

					__snake_case    :							Optional[Any]   	=				self.get_image_processor(do_normalize=_A			,						padding_value=1.0)

					__snake_case    :							Any   	=				SamProcessor.from_pretrained(self.tmpdirname			,						do_normalize=_A			,						padding_value=1.0)

					self.assertEqual(processor.image_processor.to_json_string()			,						image_processor_add_kwargs.to_json_string())
					self.assertIsInstance(processor.image_processor			,						_A)



				def       _lowercase  (self       :   Dict)					->			str:
					__snake_case    :							Dict   	=				self.get_image_processor()

					__snake_case    :							Optional[Any]   	=				SamProcessor(image_processor=_A)

					__snake_case    :							Any   	=				self.prepare_image_inputs()

					__snake_case    :							Any   	=				image_processor(_A			,						return_tensors='np')
					__snake_case    :							Optional[Any]   	=				processor(images=_A			,						return_tensors='np')

					input_feat_extract.pop('original_sizes')  # pop original_sizes as it is popped in the processor
					input_feat_extract.pop('reshaped_input_sizes')  # pop original_sizes as it is popped in the processor

					for key in input_feat_extract.keys():
						self.assertAlmostEqual(input_feat_extract[key].sum()			,						input_processor[key].sum()			,						delta=1E-2)






				@require_torch
				def       _lowercase  (self       :   List[str])					->			Optional[Any]:
					__snake_case    :							Optional[Any]   	=				self.get_image_processor()

					__snake_case    :							Optional[Any]   	=				SamProcessor(image_processor=_A)
					__snake_case    :							str   	=				[torch.ones((1, 3, 5, 5))]

					__snake_case    :							Optional[Any]   	=				[[17_64, 26_46]]

					__snake_case    :							int   	=				[[6_83, 10_24]]
					__snake_case    :							Any   	=				processor.post_process_masks(_A			,						_A			,						_A)
					self.assertEqual(masks[0].shape			,						(1, 3, 17_64, 26_46))

					__snake_case    :							str   	=				processor.post_process_masks(
					    _A			,						torch.tensor(_A)			,						torch.tensor(_A))
					self.assertEqual(masks[0].shape			,						(1, 3, 17_64, 26_46))

					# should also work with np
					__snake_case    :							Any   	=				[np.ones((1, 3, 5, 5))]
					__snake_case    :							int   	=				processor.post_process_masks(_A			,						np.array(_A)			,						np.array(_A))

					self.assertEqual(masks[0].shape			,						(1, 3, 17_64, 26_46))

					__snake_case    :							List[str]   	=				[[1, 0], [0, 1]]
					with self.assertRaises(_A):
						__snake_case    :							List[Any]   	=				processor.post_process_masks(_A			,						np.array(_A)			,						np.array(_A))







@require_vision
@require_tf
class 	UpperCamelCase    (					unittest.TestCase		):



				def       _lowercase  (self       :   int)					->			int:
					__snake_case    :							Tuple   	=				tempfile.mkdtemp()
					__snake_case    :							Tuple   	=				SamImageProcessor()
					__snake_case    :							str   	=				SamProcessor(_A)
					processor.save_pretrained(self.tmpdirname)



				def       _lowercase  (self       :   Any			,						**_A       :   Any)					->			int:
					return AutoProcessor.from_pretrained(self.tmpdirname			,						**_A).image_processor



				def       _lowercase  (self       :   Dict)					->			Optional[Any]:
					shutil.rmtree(self.tmpdirname)



				def       _lowercase  (self       :   Tuple)					->			Tuple:
					__snake_case    :							List[Any]   	=				[np.random.randint(2_55			,						size=(3, 30, 4_00)			,						dtype=np.uinta)]

					__snake_case    :							Dict   	=				[Image.fromarray(np.moveaxis(_A			,						0			,						-1)) for x in image_inputs]

					return image_inputs



				def       _lowercase  (self       :   Optional[int])					->			Dict:
					__snake_case    :							Any   	=				SamProcessor(image_processor=self.get_image_processor())
					processor.save_pretrained(self.tmpdirname)

					__snake_case    :							List[Any]   	=				self.get_image_processor(do_normalize=_A			,						padding_value=1.0)

					__snake_case    :							Optional[int]   	=				SamProcessor.from_pretrained(self.tmpdirname			,						do_normalize=_A			,						padding_value=1.0)

					self.assertEqual(processor.image_processor.to_json_string()			,						image_processor_add_kwargs.to_json_string())
					self.assertIsInstance(processor.image_processor			,						_A)



				def       _lowercase  (self       :   Optional[Any])					->			Union[str, Any]:
					__snake_case    :							Any   	=				self.get_image_processor()

					__snake_case    :							Optional[Any]   	=				SamProcessor(image_processor=_A)

					__snake_case    :							Any   	=				self.prepare_image_inputs()

					__snake_case    :							Tuple   	=				image_processor(_A			,						return_tensors='np')
					__snake_case    :							Optional[int]   	=				processor(images=_A			,						return_tensors='np')

					input_feat_extract.pop('original_sizes')  # pop original_sizes as it is popped in the processor
					input_feat_extract.pop('reshaped_input_sizes')  # pop reshaped_input_sizes as it is popped in the processor

					for key in input_feat_extract.keys():
						self.assertAlmostEqual(input_feat_extract[key].sum()			,						input_processor[key].sum()			,						delta=1E-2)






				@require_tf
				def       _lowercase  (self       :   Any)					->			List[str]:
					__snake_case    :							int   	=				self.get_image_processor()

					__snake_case    :							List[Any]   	=				SamProcessor(image_processor=_A)
					__snake_case    :							str   	=				[tf.ones((1, 3, 5, 5))]

					__snake_case    :							Any   	=				[[17_64, 26_46]]

					__snake_case    :							Any   	=				[[6_83, 10_24]]
					__snake_case    :							Dict   	=				processor.post_process_masks(_A			,						_A			,						_A			,						return_tensors='tf')
					self.assertEqual(masks[0].shape			,						(1, 3, 17_64, 26_46))

					__snake_case    :							List[Any]   	=				processor.post_process_masks(
					    _A			,						tf.convert_to_tensor(_A)			,						tf.convert_to_tensor(_A)			,						return_tensors='tf'			,						)
					self.assertEqual(masks[0].shape			,						(1, 3, 17_64, 26_46))

					# should also work with np
					__snake_case    :							Optional[int]   	=				[np.ones((1, 3, 5, 5))]
					__snake_case    :							Tuple   	=				processor.post_process_masks(
					    _A			,						np.array(_A)			,						np.array(_A)			,						return_tensors='tf')

					self.assertEqual(masks[0].shape			,						(1, 3, 17_64, 26_46))

					__snake_case    :							Optional[int]   	=				[[1, 0], [0, 1]]
					with self.assertRaises(tf.errors.InvalidArgumentError):
						__snake_case    :							List[str]   	=				processor.post_process_masks(
						    _A			,						np.array(_A)			,						np.array(_A)			,						return_tensors='tf')







@require_vision
@require_torchvision
class 	UpperCamelCase    (					unittest.TestCase		):



				def       _lowercase  (self       :   List[Any])					->			Union[str, Any]:
					__snake_case    :							Optional[int]   	=				tempfile.mkdtemp()
					__snake_case    :							str   	=				SamImageProcessor()
					__snake_case    :							Tuple   	=				SamProcessor(_A)
					processor.save_pretrained(self.tmpdirname)



				def       _lowercase  (self       :   List[str]			,						**_A       :   Dict)					->			List[str]:
					return AutoProcessor.from_pretrained(self.tmpdirname			,						**_A).image_processor



				def       _lowercase  (self       :   List[Any])					->			List[str]:
					shutil.rmtree(self.tmpdirname)



				def       _lowercase  (self       :   str)					->			str:
					__snake_case    :							str   	=				[np.random.randint(2_55			,						size=(3, 30, 4_00)			,						dtype=np.uinta)]

					__snake_case    :							List[str]   	=				[Image.fromarray(np.moveaxis(_A			,						0			,						-1)) for x in image_inputs]

					return image_inputs



				@is_pt_tf_cross_test
				def       _lowercase  (self       :   Union[str, Any])					->			int:
					__snake_case    :							List[Any]   	=				self.get_image_processor()

					__snake_case    :							Dict   	=				SamProcessor(image_processor=_A)
					__snake_case    :							Union[str, Any]   	=				np.random.randint(0			,						2			,						size=(1, 3, 5, 5)).astype(np.floataa)
					__snake_case    :							List[Any]   	=				[tf.convert_to_tensor(_A)]
					__snake_case    :							Union[str, Any]   	=				[torch.tensor(_A)]

					__snake_case    :							List[Any]   	=				[[17_64, 26_46]]

					__snake_case    :							Tuple   	=				[[6_83, 10_24]]
					__snake_case    :							List[Any]   	=				processor.post_process_masks(
					    _A			,						_A			,						_A			,						return_tensors='tf')
					__snake_case    :							int   	=				processor.post_process_masks(
					    _A			,						_A			,						_A			,						return_tensors='pt')

					self.assertTrue(np.all(tf_masks[0].numpy() == pt_masks[0].numpy()))






				@is_pt_tf_cross_test
				def       _lowercase  (self       :   List[Any])					->			Dict:
					__snake_case    :							int   	=				self.get_image_processor()

					__snake_case    :							str   	=				SamProcessor(image_processor=_A)

					__snake_case    :							str   	=				self.prepare_image_inputs()

					__snake_case    :							Optional[int]   	=				image_processor(_A			,						return_tensors='pt')['pixel_values'].numpy()
					__snake_case    :							Dict   	=				processor(images=_A			,						return_tensors='pt')['pixel_values'].numpy()

					__snake_case    :							List[str]   	=				image_processor(_A			,						return_tensors='tf')['pixel_values'].numpy()
					__snake_case    :							Optional[int]   	=				processor(images=_A			,						return_tensors='tf')['pixel_values'].numpy()

					self.assertTrue(np.allclose(_A			,						_A))
					self.assertTrue(np.allclose(_A			,						_A))
					self.assertTrue(np.allclose(_A			,						_A))






"""simple docstring"""







import math
def 						__UpperCAmelCase       (					UpperCAmelCase_					:       list    ,							UpperCAmelCase_					:       int						)							->    int:

	'''simple docstring'''





	__snake_case    :							List[str]   	=				len(UpperCAmelCase_						)
	__snake_case    :							List[Any]   	=				int(math.floor(math.sqrt(UpperCAmelCase_						)						)						)
	__snake_case    :							Any   	=				0
	while arr[min(UpperCAmelCase_    ,							UpperCAmelCase_						) - 1] < x:
		__snake_case    :							Tuple   	=				step
		step += int(math.floor(math.sqrt(UpperCAmelCase_						)						)						)
		if prev >= n:
			return -1

	while arr[prev] < x:
		__snake_case    :							Union[str, Any]   	=				prev + 1
		if prev == min(UpperCAmelCase_    ,							UpperCAmelCase_						):
			return -1
	if arr[prev] == x:
		return prev
	return -1


if __name__ == "__main__":
	_a  :  str=				input("Enter numbers separated by a comma:\n").strip()
	_a  :  int=				[int(item) for item in user_input.split(",")]
	_a  :  Optional[Any]=				int(input("Enter the number to be searched:\n"))
	_a  :  Tuple=				jump_search(arr, x)
	if res == -1:
		print("Number not found!")
	else:
		print(f'''Number {x} is at index {res}''')





