


"""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:
	A	:  Dict            =     False

if is_vision_available():
	from PIL import Image

	from transformers import PixaStructImageProcessor
class     _UpperCamelCase    (  unittest.TestCase						):
							'''simple docstring'''







							def __init__(	self       ,  __a       ,  __a=7       ,  __a=3       ,  __a=18       ,  __a=30       ,  __a=4_00       ,  __a=None       ,  __a=True       ,  __a=True       ,  __a=None       ,  ):
										__lowerCAmelCase							       =     size if size is not None else {"height": 20, "width": 20}
										__lowerCAmelCase							       =     parent
										__lowerCAmelCase							       =     batch_size
										__lowerCAmelCase							       =     num_channels
										__lowerCAmelCase							       =     image_size
										__lowerCAmelCase							       =     min_resolution
										__lowerCAmelCase							       =     max_resolution
										__lowerCAmelCase							       =     size
										__lowerCAmelCase							       =     do_normalize
										__lowerCAmelCase							       =     do_convert_rgb
										__lowerCAmelCase							       =     [5_12, 10_24, 20_48, 40_96]
										__lowerCAmelCase							       =     patch_size if patch_size is not None else {"height": 16, "width": 16}

							def      snake_case							(	self      ):
										return {"do_normalize": self.do_normalize, "do_convert_rgb": self.do_convert_rgb}



							def      snake_case							(	self      ):
										__lowerCAmelCase							       =     "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/australia.jpg"
										__lowerCAmelCase							       =     Image.open(requests.get(__a       ,  stream=__a      ).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     _UpperCamelCase    (  lowerCAmelCase__			,unittest.TestCase						):
							'''simple docstring'''







							__UpperCAmelCase		:       List[Any]							 =PixaStructImageProcessor if is_vision_available() else None

							def      snake_case							(	self      ):
										__lowerCAmelCase							       =     PixaStructImageProcessingTester(self      )

							@property
							def      snake_case							(	self      ):
										return self.image_processor_tester.prepare_image_processor_dict()

							def      snake_case							(	self      ):
										__lowerCAmelCase							       =     self.image_processing_class(**self.image_processor_dict      )
										self.assertTrue(hasattr(__a       ,  "do_normalize"      )      )
										self.assertTrue(hasattr(__a       ,  "do_convert_rgb"      )      )

							def      snake_case							(	self      ):
										__lowerCAmelCase							       =     self.image_processor_tester.prepare_dummy_image()

										__lowerCAmelCase							       =     self.image_processing_class(**self.image_processor_dict      )
										__lowerCAmelCase							       =     20_48

										__lowerCAmelCase							       =     image_processor(__a       ,  return_tensors="pt"       ,  max_patches=__a      )
										self.assertTrue(torch.allclose(inputs.flattened_patches.mean()       ,  torch.tensor(0.0_6_0_6      )       ,  atol=1e-3       ,  rtol=1e-3      )      )

							def      snake_case							(	self      ):
										# Initialize image_processor
										__lowerCAmelCase							       =     self.image_processing_class(**self.image_processor_dict      )
										# create random PIL images
										__lowerCAmelCase							       =     prepare_image_inputs(self.image_processor_tester       ,  equal_resolution=__a      )
										for image in image_inputs:
													self.assertIsInstance(__a       ,  Image.Image      )

										# Test not batched input
										__lowerCAmelCase							       =     (
										    (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
													__lowerCAmelCase							       =     image_processor(
													    image_inputs[0]       ,  return_tensors="pt"       ,  max_patches=__a      ).flattened_patches
													self.assertEqual(
													    encoded_images.shape       ,  (1, max_patch, expected_hidden_dim)       ,  )

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

							def      snake_case							(	self      ):
										# Initialize image_processor
										__lowerCAmelCase							       =     self.image_processing_class(**self.image_processor_dict      )
										# create random PIL images
										__lowerCAmelCase							       =     prepare_image_inputs(self.image_processor_tester       ,  equal_resolution=__a      )
										for image in image_inputs:
													self.assertIsInstance(__a       ,  Image.Image      )

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

										__lowerCAmelCase							       =     True

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

													__lowerCAmelCase							       =     "Hello"

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

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

							def      snake_case							(	self      ):
										# Initialize image_processor
										__lowerCAmelCase							       =     self.image_processing_class(**self.image_processor_dict      )
										# create random numpy tensors
										__lowerCAmelCase							       =     prepare_image_inputs(self.image_processor_tester       ,  equal_resolution=__a       ,  numpify=__a      )
										for image in image_inputs:
													self.assertIsInstance(__a       ,  np.ndarray      )

										__lowerCAmelCase							       =     (
										    (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
													__lowerCAmelCase							       =     image_processor(
													    image_inputs[0]       ,  return_tensors="pt"       ,  max_patches=__a      ).flattened_patches
													self.assertEqual(
													    encoded_images.shape       ,  (1, max_patch, expected_hidden_dim)       ,  )

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



							def      snake_case							(	self      ):
										# Initialize image_processor
										__lowerCAmelCase							       =     self.image_processing_class(**self.image_processor_dict      )
										# create random PyTorch tensors
										__lowerCAmelCase							       =     prepare_image_inputs(self.image_processor_tester       ,  equal_resolution=__a       ,  torchify=__a      )
										for image in image_inputs:
													self.assertIsInstance(__a       ,  torch.Tensor      )

										# Test not batched input
										__lowerCAmelCase							       =     (
										    (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
													__lowerCAmelCase							       =     image_processor(
													    image_inputs[0]       ,  return_tensors="pt"       ,  max_patches=__a      ).flattened_patches
													self.assertEqual(
													    encoded_images.shape       ,  (1, max_patch, expected_hidden_dim)       ,  )

													# Test batched
													__lowerCAmelCase							       =     image_processor(
													    __a       ,  return_tensors="pt"       ,  max_patches=__a      ).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     _UpperCamelCase    (  lowerCAmelCase__			,unittest.TestCase						):
							'''simple docstring'''







							__UpperCAmelCase		:       List[Any]							 =PixaStructImageProcessor if is_vision_available() else None

							def      snake_case							(	self      ):
										__lowerCAmelCase							       =     PixaStructImageProcessingTester(self       ,  num_channels=4      )
										__lowerCAmelCase							       =     3

							@property
							def      snake_case							(	self      ):
										return self.image_processor_tester.prepare_image_processor_dict()

							def      snake_case							(	self      ):
										__lowerCAmelCase							       =     self.image_processing_class(**self.image_processor_dict      )
										self.assertTrue(hasattr(__a       ,  "do_normalize"      )      )
										self.assertTrue(hasattr(__a       ,  "do_convert_rgb"      )      )



							def      snake_case							(	self      ):
										# Initialize image_processor
										__lowerCAmelCase							       =     self.image_processing_class(**self.image_processor_dict      )
										# create random PIL images
										__lowerCAmelCase							       =     prepare_image_inputs(self.image_processor_tester       ,  equal_resolution=__a      )
										for image in image_inputs:
													self.assertIsInstance(__a       ,  Image.Image      )

										# Test not batched input
										__lowerCAmelCase							       =     (
										    (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
													__lowerCAmelCase							       =     image_processor(
													    image_inputs[0]       ,  return_tensors="pt"       ,  max_patches=__a      ).flattened_patches
													self.assertEqual(
													    encoded_images.shape       ,  (1, max_patch, expected_hidden_dim)       ,  )

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








"""simple docstring"""


def _lowerCamelCase      (						_UpperCamelCase ):

			'''simple docstring'''




			__lowerCAmelCase							       =     False
			while is_sorted is False:  # Until all the indices are traversed keep looping
						__lowerCAmelCase							       =     True
						for i in range(0       ,					len(_UpperCamelCase ) - 1       ,					2 ):  # iterating over all even indices
									if input_list[i] > input_list[i + 1]:
												__lowerCAmelCase       ,      __lowerCAmelCase							       =     input_list[i + 1], input_list[i]
												# swapping if elements not in order
												__lowerCAmelCase							       =     False

						for i in range(1       ,					len(_UpperCamelCase ) - 1       ,					2 ):  # iterating over all odd indices
									if input_list[i] > input_list[i + 1]:
												__lowerCAmelCase       ,      __lowerCAmelCase							       =     input_list[i + 1], input_list[i]
												# swapping if elements not in order
												__lowerCAmelCase							       =     False
			return input_list


if __name__ == "__main__":
	print("Enter list to be sorted")
	A	:  Tuple            =     [int(x) for x in input().split()]
	# inputing elements of the list in one line
	A	:  Dict            =     odd_even_sort(input_list)
	print("The sorted list is")
	print(sorted_list)




