



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 BlipImageProcessor


class 	a__       (       unittest.TestCase       ):


					"""simple docstring"""



					def __init__(		self     :Union[str, Any]      ,  lowercase__     :Optional[int]      ,  lowercase__     :str=7      ,  lowercase__     :Tuple=3      ,  lowercase__     :int=18      ,  lowercase__     :Union[str, Any]=30      ,  lowercase__     :Optional[Any]=400      ,  lowercase__     :List[Any]=True      ,  lowercase__     :Union[str, Any]=None      ,  lowercase__     :Tuple=True      ,  lowercase__     :Union[str, Any]=False      ,  lowercase__     :List[Any]=[0.4814_5466, 0.457_8275, 0.4082_1073]      ,  lowercase__     :str=[0.2686_2954, 0.2613_0258, 0.2757_7711]      ,  lowercase__     :Optional[int]=True      ,  ):
										lowercase						   =       size if size is not None else {'height': 20, 'width': 20}
										lowercase						   =       parent
										lowercase						   =       batch_size
										lowercase						   =       num_channels
										lowercase						   =       image_size
										lowercase						   =       min_resolution
										lowercase						   =       max_resolution
										lowercase						   =       do_resize
										lowercase						   =       size
										lowercase						   =       do_normalize
										lowercase						   =       image_mean
										lowercase						   =       image_std
										lowercase						   =       do_pad
										lowercase						   =       do_convert_rgb

					def 				__UpperCAmelCase		(		self     :Any    ):
										return {
										    "do_resize": self.do_resize,
										    "size": self.size,
										    "do_normalize": self.do_normalize,
										    "image_mean": self.image_mean,
										    "image_std": self.image_std,
										    "do_convert_rgb": self.do_convert_rgb,
										    "do_pad": self.do_pad,
										}



					def 				__UpperCAmelCase		(		self     :Optional[int]      ,  lowercase__     :Any=False      ,  lowercase__     :int=False      ,  lowercase__     :Optional[Any]=False    ):
										assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

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

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

										if torchify:
															lowercase						   =       [torch.from_numpy(lowercase__    ) for x in image_inputs]

										return image_inputs




@require_torch
@require_vision
class 	a__       (       _snake_case  ,			unittest.TestCase       ):


					"""simple docstring"""



					A__  :				List[Any]					 =				BlipImageProcessor if is_vision_available() else None

					def 				__UpperCAmelCase		(		self     :List[Any]    ):
										lowercase						   =       BlipImageProcessingTester(self    )

					@property
					def 				__UpperCAmelCase		(		self     :Any    ):
										return self.image_processor_tester.prepare_image_processor_dict()

					def 				__UpperCAmelCase		(		self     :Optional[Any]    ):
										lowercase						   =       self.image_processing_class(**self.image_processor_dict    )
										self.assertTrue(hasattr(lowercase__      ,  'do_resize'    )    )
										self.assertTrue(hasattr(lowercase__      ,  'size'    )    )
										self.assertTrue(hasattr(lowercase__      ,  'do_normalize'    )    )
										self.assertTrue(hasattr(lowercase__      ,  'image_mean'    )    )
										self.assertTrue(hasattr(lowercase__      ,  'image_std'    )    )
										self.assertTrue(hasattr(lowercase__      ,  'do_convert_rgb'    )    )

					def 				__UpperCAmelCase		(		self     :Tuple    ):
										pass

					def 				__UpperCAmelCase		(		self     :str    ):
										# Initialize image_processor
										lowercase						   =       self.image_processing_class(**self.image_processor_dict    )
										# create random PIL images
										lowercase						   =       self.image_processor_tester.prepare_inputs(equal_resolution=lowercase__    )
										for image in image_inputs:
															self.assertIsInstance(lowercase__      ,  Image.Image    )

										# Test not batched input
										lowercase						   =       image_processor(image_inputs[0]      ,  return_tensors='pt'    ).pixel_values
										self.assertEqual(
										    encoded_images.shape      ,  (
										        1,
										        self.image_processor_tester.num_channels,
										        self.image_processor_tester.size['height'],
										        self.image_processor_tester.size['width'],
										    )      ,  )

										# Test batched
										lowercase						   =       image_processor(lowercase__      ,  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.size['height'],
										        self.image_processor_tester.size['width'],
										    )      ,  )

					def 				__UpperCAmelCase		(		self     :List[Any]    ):
										# Initialize image_processor
										lowercase						   =       self.image_processing_class(**self.image_processor_dict    )
										# create random numpy tensors
										lowercase						   =       self.image_processor_tester.prepare_inputs(equal_resolution=lowercase__      ,  numpify=lowercase__    )
										for image in image_inputs:
															self.assertIsInstance(lowercase__      ,  np.ndarray    )

										# Test not batched input
										lowercase						   =       image_processor(image_inputs[0]      ,  return_tensors='pt'    ).pixel_values
										self.assertEqual(
										    encoded_images.shape      ,  (
										        1,
										        self.image_processor_tester.num_channels,
										        self.image_processor_tester.size['height'],
										        self.image_processor_tester.size['width'],
										    )      ,  )

										# Test batched
										lowercase						   =       image_processor(lowercase__      ,  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.size['height'],
										        self.image_processor_tester.size['width'],
										    )      ,  )



					def 				__UpperCAmelCase		(		self     :Optional[Any]    ):
										# Initialize image_processor
										lowercase						   =       self.image_processing_class(**self.image_processor_dict    )
										# create random PyTorch tensors
										lowercase						   =       self.image_processor_tester.prepare_inputs(equal_resolution=lowercase__      ,  torchify=lowercase__    )
										for image in image_inputs:
															self.assertIsInstance(lowercase__      ,  torch.Tensor    )

										# Test not batched input
										lowercase						   =       image_processor(image_inputs[0]      ,  return_tensors='pt'    ).pixel_values
										self.assertEqual(
										    encoded_images.shape      ,  (
										        1,
										        self.image_processor_tester.num_channels,
										        self.image_processor_tester.size['height'],
										        self.image_processor_tester.size['width'],
										    )      ,  )

										# Test batched
										lowercase						   =       image_processor(lowercase__      ,  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.size['height'],
										        self.image_processor_tester.size['width'],
										    )      ,  )




@require_torch
@require_vision
class 	a__       (       _snake_case  ,			unittest.TestCase       ):


					"""simple docstring"""



					A__  :				Tuple					 =				BlipImageProcessor if is_vision_available() else None

					def 				__UpperCAmelCase		(		self     :Dict    ):
										lowercase						   =       BlipImageProcessingTester(self      ,  num_channels=4    )
										lowercase						   =       3

					@property
					def 				__UpperCAmelCase		(		self     :Any    ):
										return self.image_processor_tester.prepare_image_processor_dict()

					def 				__UpperCAmelCase		(		self     :List[str]    ):
										lowercase						   =       self.image_processing_class(**self.image_processor_dict    )
										self.assertTrue(hasattr(lowercase__      ,  'do_resize'    )    )
										self.assertTrue(hasattr(lowercase__      ,  'size'    )    )
										self.assertTrue(hasattr(lowercase__      ,  'do_normalize'    )    )
										self.assertTrue(hasattr(lowercase__      ,  'image_mean'    )    )
										self.assertTrue(hasattr(lowercase__      ,  'image_std'    )    )
										self.assertTrue(hasattr(lowercase__      ,  'do_convert_rgb'    )    )

					def 				__UpperCAmelCase		(		self     :Dict    ):
										pass



					def 				__UpperCAmelCase		(		self     :Union[str, Any]    ):
										# Initialize image_processor
										lowercase						   =       self.image_processing_class(**self.image_processor_dict    )
										# create random PIL images
										lowercase						   =       self.image_processor_tester.prepare_inputs(equal_resolution=lowercase__    )
										for image in image_inputs:
															self.assertIsInstance(lowercase__      ,  Image.Image    )

										# Test not batched input
										lowercase						   =       image_processor(image_inputs[0]      ,  return_tensors='pt'    ).pixel_values
										self.assertEqual(
										    encoded_images.shape      ,  (
										        1,
										        self.expected_encoded_image_num_channels,
										        self.image_processor_tester.size['height'],
										        self.image_processor_tester.size['width'],
										    )      ,  )

										# Test batched
										lowercase						   =       image_processor(lowercase__      ,  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.size['height'],
										        self.image_processor_tester.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}""")






