






"""simple docstring"""

import unittest

import numpy as np
import requests

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, prepare_image_inputs


if is_torch_available():
			import torch

			from transformers.pytorch_utils import is_torch_greater_or_equal_than_1_11
else:
			lowercase    			=				False

if is_vision_available():
			from PIL import Image

			from transformers import PixaStructImageProcessor

class 						A_							(      unittest.TestCase  ):







				def __init__(							self							:						Any						,    __lowerCamelCase							:						Optional[int]						,    __lowerCamelCase							:						int=7						,    __lowerCamelCase							:						Optional[int]=3						,    __lowerCamelCase							:						str=1_8						,    __lowerCamelCase							:						List[Any]=3_0						,    __lowerCamelCase							:						Dict=4_0_0						,    __lowerCamelCase							:						List[Any]=None						,    __lowerCamelCase							:						Optional[int]=True						,    __lowerCamelCase							:						Dict=True						,    __lowerCamelCase							:						int=None						,    )				->					Optional[Any]:
										__magic_name__            =     size if size is not None else {"height": 2_0, "width": 2_0}
										__magic_name__            =     parent
										__magic_name__            =     batch_size
										__magic_name__            =     num_channels
										__magic_name__            =     image_size
										__magic_name__            =     min_resolution
										__magic_name__            =     max_resolution
										__magic_name__            =     size
										__magic_name__            =     do_normalize
										__magic_name__            =     do_convert_rgb
										__magic_name__            =     [5_1_2, 1_0_2_4, 2_0_4_8, 4_0_9_6]
										__magic_name__            =     patch_size if patch_size is not None else {"height": 1_6, "width": 1_6}







				def     _snake_case					(							self							:						str	)				->					Tuple:
										return {"do_normalize": self.do_normalize, "do_convert_rgb": self.do_convert_rgb}







				def     _snake_case					(							self							:						List[Any]	)				->					Optional[int]:
										__magic_name__            =     "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/australia.jpg"
										__magic_name__            =     Image.open(requests.get(_lowerCAmelCase						,    stream=_lowerCAmelCase	).raw	).convert("RGB"	)
										return raw_image





@unittest.skipIf(
    not is_torch_greater_or_equal_than_1_11					,							reason='''`Pix2StructImageProcessor` requires `torch>=1.11.0`.'''					,							)
@require_torch
@require_vision
class 						A_							(      _lowerCAmelCase					,							unittest.TestCase  ):
				UpperCAmelCase__        =				PixaStructImageProcessor if is_vision_available() else None







				def     _snake_case					(							self							:						List[str]	)				->					Union[str, Any]:
										__magic_name__            =     PixaStructImageProcessingTester(self	)







				@property
				def     _snake_case					(							self							:						Union[str, Any]	)				->					Optional[Any]:
										return self.image_processor_tester.prepare_image_processor_dict()







				def     _snake_case					(							self							:						Any	)				->					Optional[Any]:
										__magic_name__            =     self.image_processing_class(**self.image_processor_dict	)
										self.assertTrue(hasattr(_lowerCAmelCase						,    "do_normalize"	)	)
										self.assertTrue(hasattr(_lowerCAmelCase						,    "do_convert_rgb"	)	)







				def     _snake_case					(							self							:						Tuple	)				->					str:
										__magic_name__            =     self.image_processor_tester.prepare_dummy_image()

										__magic_name__            =     self.image_processing_class(**self.image_processor_dict	)
										__magic_name__            =     2_0_4_8

										__magic_name__            =     image_processor(_lowerCAmelCase						,    return_tensors="pt"						,    max_patches=_lowerCAmelCase	)
										self.assertTrue(torch.allclose(inputs.flattened_patches.mean()						,    torch.tensor(0.0606	)						,    atol=1e-3						,    rtol=1e-3	)	)







				def     _snake_case					(							self							:						Any	)				->					Any:
										__magic_name__            =     self.image_processing_class(**self.image_processor_dict	)
										# create random PIL images
										__magic_name__            =     prepare_image_inputs(self.image_processor_tester						,    equal_resolution=_lowerCAmelCase	)
										for image in image_inputs:
																self.assertIsInstance(_lowerCAmelCase						,    Image.Image	)

										# Test not batched input
										__magic_name__            =     (
										    (self.image_processor_tester.patch_size["height"] * self.image_processor_tester.patch_size["width"])
										    * self.image_processor_tester.num_channels
										) + 2

										for max_patch in self.image_processor_tester.max_patches:
																# Test not batched input
																__magic_name__            =     image_processor(
																    image_inputs[0]						,    return_tensors="pt"						,    max_patches=_lowerCAmelCase	).flattened_patches
																self.assertEqual(
																    encoded_images.shape						,    (1, max_patch, expected_hidden_dim)						,    )

																# Test batched
																__magic_name__            =     image_processor(
																    _lowerCAmelCase						,    return_tensors="pt"						,    max_patches=_lowerCAmelCase	).flattened_patches
																self.assertEqual(
																    encoded_images.shape						,    (self.image_processor_tester.batch_size, max_patch, expected_hidden_dim)						,    )







				def     _snake_case					(							self							:						List[Any]	)				->					Union[str, Any]:
										__magic_name__            =     self.image_processing_class(**self.image_processor_dict	)
										# create random PIL images
										__magic_name__            =     prepare_image_inputs(self.image_processor_tester						,    equal_resolution=_lowerCAmelCase	)
										for image in image_inputs:
																self.assertIsInstance(_lowerCAmelCase						,    Image.Image	)

										# Test not batched input
										__magic_name__            =     (
										    (self.image_processor_tester.patch_size["height"] * self.image_processor_tester.patch_size["width"])
										    * self.image_processor_tester.num_channels
										) + 2

										__magic_name__            =     True

										for max_patch in self.image_processor_tester.max_patches:
																# Test not batched input
																with self.assertRaises(_lowerCAmelCase	):
																						__magic_name__            =     image_processor(
																						    image_inputs[0]						,    return_tensors="pt"						,    max_patches=_lowerCAmelCase	).flattened_patches

																__magic_name__            =     "Hello"

																__magic_name__            =     image_processor(
																    image_inputs[0]						,    return_tensors="pt"						,    max_patches=_lowerCAmelCase						,    header_text=_lowerCAmelCase	).flattened_patches
																self.assertEqual(
																    encoded_images.shape						,    (1, max_patch, expected_hidden_dim)						,    )

																# Test batched
																__magic_name__            =     image_processor(
																    _lowerCAmelCase						,    return_tensors="pt"						,    max_patches=_lowerCAmelCase						,    header_text=_lowerCAmelCase	).flattened_patches
																self.assertEqual(
																    encoded_images.shape						,    (self.image_processor_tester.batch_size, max_patch, expected_hidden_dim)						,    )







				def     _snake_case					(							self							:						List[str]	)				->					List[str]:
										__magic_name__            =     self.image_processing_class(**self.image_processor_dict	)
										# create random numpy tensors
										__magic_name__            =     prepare_image_inputs(self.image_processor_tester						,    equal_resolution=_lowerCAmelCase						,    numpify=_lowerCAmelCase	)
										for image in image_inputs:
																self.assertIsInstance(_lowerCAmelCase						,    np.ndarray	)

										__magic_name__            =     (
										    (self.image_processor_tester.patch_size["height"] * self.image_processor_tester.patch_size["width"])
										    * self.image_processor_tester.num_channels
										) + 2

										for max_patch in self.image_processor_tester.max_patches:
																# Test not batched input
																__magic_name__            =     image_processor(
																    image_inputs[0]						,    return_tensors="pt"						,    max_patches=_lowerCAmelCase	).flattened_patches
																self.assertEqual(
																    encoded_images.shape						,    (1, max_patch, expected_hidden_dim)						,    )

																# Test batched
																__magic_name__            =     image_processor(
																    _lowerCAmelCase						,    return_tensors="pt"						,    max_patches=_lowerCAmelCase	).flattened_patches
																self.assertEqual(
																    encoded_images.shape						,    (self.image_processor_tester.batch_size, max_patch, expected_hidden_dim)						,    )







				def     _snake_case					(							self							:						List[str]	)				->					Optional[int]:
										__magic_name__            =     self.image_processing_class(**self.image_processor_dict	)
										# create random PyTorch tensors
										__magic_name__            =     prepare_image_inputs(self.image_processor_tester						,    equal_resolution=_lowerCAmelCase						,    torchify=_lowerCAmelCase	)
										for image in image_inputs:
																self.assertIsInstance(_lowerCAmelCase						,    torch.Tensor	)

										# Test not batched input
										__magic_name__            =     (
										    (self.image_processor_tester.patch_size["height"] * self.image_processor_tester.patch_size["width"])
										    * self.image_processor_tester.num_channels
										) + 2

										for max_patch in self.image_processor_tester.max_patches:
																# Test not batched input
																__magic_name__            =     image_processor(
																    image_inputs[0]						,    return_tensors="pt"						,    max_patches=_lowerCAmelCase	).flattened_patches
																self.assertEqual(
																    encoded_images.shape						,    (1, max_patch, expected_hidden_dim)						,    )

																# Test batched
																__magic_name__            =     image_processor(
																    _lowerCAmelCase						,    return_tensors="pt"						,    max_patches=_lowerCAmelCase	).flattened_patches
																self.assertEqual(
																    encoded_images.shape						,    (self.image_processor_tester.batch_size, max_patch, expected_hidden_dim)						,    )





@unittest.skipIf(
    not is_torch_greater_or_equal_than_1_11					,							reason='''`Pix2StructImageProcessor` requires `torch>=1.11.0`.'''					,							)
@require_torch
@require_vision
class 						A_							(      _lowerCAmelCase					,							unittest.TestCase  ):
				UpperCAmelCase__        =				PixaStructImageProcessor if is_vision_available() else None







				def     _snake_case					(							self							:						Dict	)				->					Union[str, Any]:
										__magic_name__            =     PixaStructImageProcessingTester(self						,    num_channels=4	)
										__magic_name__            =     3







				@property
				def     _snake_case					(							self							:						int	)				->					int:
										return self.image_processor_tester.prepare_image_processor_dict()







				def     _snake_case					(							self							:						Any	)				->					List[str]:
										__magic_name__            =     self.image_processing_class(**self.image_processor_dict	)
										self.assertTrue(hasattr(_lowerCAmelCase						,    "do_normalize"	)	)
										self.assertTrue(hasattr(_lowerCAmelCase						,    "do_convert_rgb"	)	)







				def     _snake_case					(							self							:						Dict	)				->					int:
										__magic_name__            =     self.image_processing_class(**self.image_processor_dict	)
										# create random PIL images
										__magic_name__            =     prepare_image_inputs(self.image_processor_tester						,    equal_resolution=_lowerCAmelCase	)
										for image in image_inputs:
																self.assertIsInstance(_lowerCAmelCase						,    Image.Image	)

										# Test not batched input
										__magic_name__            =     (
										    (self.image_processor_tester.patch_size["height"] * self.image_processor_tester.patch_size["width"])
										    * (self.image_processor_tester.num_channels - 1)
										) + 2

										for max_patch in self.image_processor_tester.max_patches:
																# Test not batched input
																__magic_name__            =     image_processor(
																    image_inputs[0]						,    return_tensors="pt"						,    max_patches=_lowerCAmelCase	).flattened_patches
																self.assertEqual(
																    encoded_images.shape						,    (1, max_patch, expected_hidden_dim)						,    )

																# Test batched
																__magic_name__            =     image_processor(
																    _lowerCAmelCase						,    return_tensors="pt"						,    max_patches=_lowerCAmelCase	).flattened_patches
																self.assertEqual(
																    encoded_images.shape						,    (self.image_processor_tester.batch_size, max_patch, expected_hidden_dim)						,    )











"""simple docstring"""

def _lowerCAmelCase	(  __lowerCamelCase:list   ):

						'''simple docstring'''






						__magic_name__            =     len(__lowerCamelCase   )
						for i in range(1 ,						__lowerCamelCase   ):
												__magic_name__            =     collection[i]
												__magic_name__            =     0
												__magic_name__            =     i - 1

												while low <= high:
																		__magic_name__            =     (low + high) // 2
																		if val < collection[mid]:
																								__magic_name__            =     mid - 1
																		else:
																								__magic_name__            =     mid + 1
												for j in range(__lowerCamelCase ,						__lowerCamelCase ,						-1   ):
																		__magic_name__            =     collection[j - 1]
												__magic_name__            =     val
						return collection


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



