


"""simple docstring"""
import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin


if is_torch_available():
			import torch

if is_vision_available():
			from PIL import Image

			from transformers import CLIPImageProcessor



class      _UpperCAmelCase					(				unittest.TestCase							):






		'''simple docstring'''

		def __init__(self							,			a_							,			a_=7							,			a_=3							,			a_=18							,			a_=30							,			a_=4_00							,			a_=True							,			a_=None							,			a_=True							,			a_=None							,			a_=True							,			a_=[0.4814_5466, 0.457_8275, 0.4082_1073]							,			a_=[0.2686_2954, 0.2613_0258, 0.2757_7711]							,			a_=True							,			):





			'''simple docstring'''

			__snake_case      :		Any         =							size if size is not None else {'''shortest_edge''': 20}
			__snake_case      :		Optional[int]         =							crop_size if crop_size is not None else {'''height''': 18, '''width''': 18}
			__snake_case      :		Dict         =							parent
			__snake_case      :		List[Any]         =							batch_size
			__snake_case      :		str         =							num_channels
			__snake_case      :		Optional[int]         =							image_size
			__snake_case      :		Any         =							min_resolution
			__snake_case      :		Tuple         =							max_resolution
			__snake_case      :		Optional[int]         =							do_resize
			__snake_case      :		int         =							size
			__snake_case      :		int         =							do_center_crop
			__snake_case      :		Optional[Any]         =							crop_size
			__snake_case      :		Union[str, Any]         =							do_normalize
			__snake_case      :		Optional[int]         =							image_mean
			__snake_case      :		Optional[Any]         =							image_std
			__snake_case      :		Optional[int]         =							do_convert_rgb



		def 							SCREAMING_SNAKE_CASE    (self   ):





			'''simple docstring'''

			return {
			    "do_resize": self.do_resize,
			    "size": self.size,
			    "do_center_crop": self.do_center_crop,
			    "crop_size": self.crop_size,
			    "do_normalize": self.do_normalize,
			    "image_mean": self.image_mean,
			    "image_std": self.image_std,
			    "do_convert_rgb": self.do_convert_rgb,
			}



		def 							SCREAMING_SNAKE_CASE    (self							,			a_=False							,			a_=False							,			a_=False   ):





			'''simple docstring'''

			assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

			if equal_resolution:
				__snake_case      :		Dict         =							[]
				for i in range(self.batch_size   ):
					image_inputs.append(
					    np.random.randint(
					        2_55							,			size=(self.num_channels, self.max_resolution, self.max_resolution)							,			dtype=np.uinta   )   )
			else:
				__snake_case      :		List[str]         =							[]
				for i in range(self.batch_size   ):
					__snake_case      ,				__snake_case      :		Dict         =							np.random.choice(np.arange(self.min_resolution							,			self.max_resolution   )							,			2   )
					image_inputs.append(np.random.randint(2_55							,			size=(self.num_channels, width, height)							,			dtype=np.uinta   )   )

			if not numpify and not torchify:
				# PIL expects the channel dimension as last dimension
				__snake_case      :		Dict         =							[Image.fromarray(np.moveaxis(a_							,			0							,			-1   )   ) for x in image_inputs]

			if torchify:
				__snake_case      :		Dict         =							[torch.from_numpy(a_   ) for x in image_inputs]

			return image_inputs



@require_torch
@require_vision
class      _UpperCAmelCase					(				__snake_case,							unittest.TestCase							):






		'''simple docstring'''

		lowerCamelCase__           =CLIPImageProcessor if is_vision_available() else None



		def 							SCREAMING_SNAKE_CASE    (self   ):





			'''simple docstring'''

			__snake_case      :		int         =							CLIPImageProcessingTester(self   )



		@property
		def 							SCREAMING_SNAKE_CASE    (self   ):





			'''simple docstring'''

			return self.image_processor_tester.prepare_image_processor_dict()



		def 							SCREAMING_SNAKE_CASE    (self   ):





			'''simple docstring'''

			__snake_case      :		int         =							self.image_processing_class(**self.image_processor_dict   )
			self.assertTrue(hasattr(a_							,			'''do_resize'''   )   )
			self.assertTrue(hasattr(a_							,			'''size'''   )   )
			self.assertTrue(hasattr(a_							,			'''do_center_crop'''   )   )
			self.assertTrue(hasattr(a_							,			'''center_crop'''   )   )
			self.assertTrue(hasattr(a_							,			'''do_normalize'''   )   )
			self.assertTrue(hasattr(a_							,			'''image_mean'''   )   )
			self.assertTrue(hasattr(a_							,			'''image_std'''   )   )
			self.assertTrue(hasattr(a_							,			'''do_convert_rgb'''   )   )



		def 							SCREAMING_SNAKE_CASE    (self   ):





			'''simple docstring'''

			__snake_case      :		Any         =							self.image_processing_class.from_dict(self.image_processor_dict   )
			self.assertEqual(image_processor.size							,			{'''shortest_edge''': 20}   )
			self.assertEqual(image_processor.crop_size							,			{'''height''': 18, '''width''': 18}   )

			__snake_case      :		int         =							self.image_processing_class.from_dict(self.image_processor_dict							,			size=42							,			crop_size=84   )
			self.assertEqual(image_processor.size							,			{'''shortest_edge''': 42}   )
			self.assertEqual(image_processor.crop_size							,			{'''height''': 84, '''width''': 84}   )



		def 							SCREAMING_SNAKE_CASE    (self   ):





			'''simple docstring'''

			pass



		def 							SCREAMING_SNAKE_CASE    (self   ):





			'''simple docstring'''

			__snake_case      :		Optional[Any]         =							self.image_processing_class(**self.image_processor_dict   )
			# create random PIL images
			__snake_case      :		Tuple         =							self.image_processor_tester.prepare_inputs(equal_resolution=a_   )
			for image in image_inputs:
				self.assertIsInstance(a_							,			Image.Image   )

			# Test not batched input
			__snake_case      :		Union[str, Any]         =							image_processing(image_inputs[0]							,			return_tensors='''pt'''   ).pixel_values
			self.assertEqual(
			    encoded_images.shape							,			(
			        1,
			        self.image_processor_tester.num_channels,
			        self.image_processor_tester.crop_size['''height'''],
			        self.image_processor_tester.crop_size['''width'''],
			    )							,			)

			# Test batched
			__snake_case      :		str         =							image_processing(a_							,			return_tensors='''pt'''   ).pixel_values
			self.assertEqual(
			    encoded_images.shape							,			(
			        self.image_processor_tester.batch_size,
			        self.image_processor_tester.num_channels,
			        self.image_processor_tester.crop_size['''height'''],
			        self.image_processor_tester.crop_size['''width'''],
			    )							,			)



		def 							SCREAMING_SNAKE_CASE    (self   ):





			'''simple docstring'''

			__snake_case      :		Optional[Any]         =							self.image_processing_class(**self.image_processor_dict   )
			# create random numpy tensors
			__snake_case      :		int         =							self.image_processor_tester.prepare_inputs(equal_resolution=a_							,			numpify=a_   )
			for image in image_inputs:
				self.assertIsInstance(a_							,			np.ndarray   )

			# Test not batched input
			__snake_case      :		Optional[Any]         =							image_processing(image_inputs[0]							,			return_tensors='''pt'''   ).pixel_values
			self.assertEqual(
			    encoded_images.shape							,			(
			        1,
			        self.image_processor_tester.num_channels,
			        self.image_processor_tester.crop_size['''height'''],
			        self.image_processor_tester.crop_size['''width'''],
			    )							,			)

			# Test batched
			__snake_case      :		Union[str, Any]         =							image_processing(a_							,			return_tensors='''pt'''   ).pixel_values
			self.assertEqual(
			    encoded_images.shape							,			(
			        self.image_processor_tester.batch_size,
			        self.image_processor_tester.num_channels,
			        self.image_processor_tester.crop_size['''height'''],
			        self.image_processor_tester.crop_size['''width'''],
			    )							,			)



		def 							SCREAMING_SNAKE_CASE    (self   ):





			'''simple docstring'''

			__snake_case      :		str         =							self.image_processing_class(**self.image_processor_dict   )
			# create random PyTorch tensors
			__snake_case      :		List[Any]         =							self.image_processor_tester.prepare_inputs(equal_resolution=a_							,			torchify=a_   )
			for image in image_inputs:
				self.assertIsInstance(a_							,			torch.Tensor   )

			# Test not batched input
			__snake_case      :		str         =							image_processing(image_inputs[0]							,			return_tensors='''pt'''   ).pixel_values
			self.assertEqual(
			    encoded_images.shape							,			(
			        1,
			        self.image_processor_tester.num_channels,
			        self.image_processor_tester.crop_size['''height'''],
			        self.image_processor_tester.crop_size['''width'''],
			    )							,			)

			# Test batched
			__snake_case      :		Any         =							image_processing(a_							,			return_tensors='''pt'''   ).pixel_values
			self.assertEqual(
			    encoded_images.shape							,			(
			        self.image_processor_tester.batch_size,
			        self.image_processor_tester.num_channels,
			        self.image_processor_tester.crop_size['''height'''],
			        self.image_processor_tester.crop_size['''width'''],
			    )							,			)



@require_torch
@require_vision
class      _UpperCAmelCase					(				__snake_case,							unittest.TestCase							):






		'''simple docstring'''

		lowerCamelCase__           =CLIPImageProcessor if is_vision_available() else None



		def 							SCREAMING_SNAKE_CASE    (self   ):





			'''simple docstring'''

			__snake_case      :		List[str]         =							CLIPImageProcessingTester(self							,			num_channels=4   )
			__snake_case      :		Optional[Any]         =							3



		@property
		def 							SCREAMING_SNAKE_CASE    (self   ):





			'''simple docstring'''

			return self.image_processor_tester.prepare_image_processor_dict()



		def 							SCREAMING_SNAKE_CASE    (self   ):





			'''simple docstring'''

			__snake_case      :		Union[str, Any]         =							self.image_processing_class(**self.image_processor_dict   )
			self.assertTrue(hasattr(a_							,			'''do_resize'''   )   )
			self.assertTrue(hasattr(a_							,			'''size'''   )   )
			self.assertTrue(hasattr(a_							,			'''do_center_crop'''   )   )
			self.assertTrue(hasattr(a_							,			'''center_crop'''   )   )
			self.assertTrue(hasattr(a_							,			'''do_normalize'''   )   )
			self.assertTrue(hasattr(a_							,			'''image_mean'''   )   )
			self.assertTrue(hasattr(a_							,			'''image_std'''   )   )
			self.assertTrue(hasattr(a_							,			'''do_convert_rgb'''   )   )



		def 							SCREAMING_SNAKE_CASE    (self   ):





			'''simple docstring'''

			pass



		def 							SCREAMING_SNAKE_CASE    (self   ):





			'''simple docstring'''

			__snake_case      :		Tuple         =							self.image_processing_class(**self.image_processor_dict   )
			# create random PIL images
			__snake_case      :		Optional[Any]         =							self.image_processor_tester.prepare_inputs(equal_resolution=a_   )
			for image in image_inputs:
				self.assertIsInstance(a_							,			Image.Image   )

			# Test not batched input
			__snake_case      :		int         =							image_processing(image_inputs[0]							,			return_tensors='''pt'''   ).pixel_values
			self.assertEqual(
			    encoded_images.shape							,			(
			        1,
			        self.expected_encoded_image_num_channels,
			        self.image_processor_tester.crop_size['''height'''],
			        self.image_processor_tester.crop_size['''width'''],
			    )							,			)

			# Test batched
			__snake_case      :		Optional[int]         =							image_processing(a_							,			return_tensors='''pt'''   ).pixel_values
			self.assertEqual(
			    encoded_images.shape							,			(
			        self.image_processor_tester.batch_size,
			        self.expected_encoded_image_num_channels,
			        self.image_processor_tester.crop_size['''height'''],
			        self.image_processor_tester.crop_size['''width'''],
			    )							,			)










def 		__snake_case						(    _UpperCAmelCase       ,			_UpperCAmelCase				):
					"""simple docstring"""






					for index, item in enumerate(_UpperCAmelCase				):
										if item == target:
															return index
					return -1





def 		__snake_case						(    _UpperCAmelCase       ,			_UpperCAmelCase       ,			_UpperCAmelCase       ,			_UpperCAmelCase				):
					"""simple docstring"""






					if not (0 <= high < len(_UpperCAmelCase				) and 0 <= low < len(_UpperCAmelCase				)):
										raise Exception('Invalid upper or lower bound!'				)
					if high < low:
										return -1
					if sequence[low] == target:
										return low
					if sequence[high] == target:
										return high
					return rec_linear_search(_UpperCAmelCase       ,			low + 1       ,			high - 1       ,			_UpperCAmelCase				)


if __name__ == "__main__":
		__magic_name__       =     input('''Enter numbers separated by comma:\n''').strip()
		__magic_name__       =     [int(item.strip()) for item in user_input.split(''',''')]

		__magic_name__       =     int(input('''Enter a single number to be found in the list:\n''').strip())
		__magic_name__       =     linear_search(sequence, target)
		if result != -1:
				print(F"""linear_search({sequence}, {target}) = {result}""")
		else:
				print(F"""{target} was not found in {sequence}""")






