



from __future__ import annotations

import copy
import inspect
import unittest

import numpy as np

from transformers import is_tf_available, is_vision_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_tf, slow
from transformers.utils import cached_property

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
						import tensorflow as tf

						from transformers import (
						    TF_LAYOUTLMV3_PRETRAINED_MODEL_ARCHIVE_LIST,
						    TF_MODEL_FOR_MULTIPLE_CHOICE_MAPPING,
						    TF_MODEL_FOR_QUESTION_ANSWERING_MAPPING,
						    TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING,
						    TF_MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING,
						    LayoutLMvaConfig,
						    TFLayoutLMvaForQuestionAnswering,
						    TFLayoutLMvaForSequenceClassification,
						    TFLayoutLMvaForTokenClassification,
						    TFLayoutLMvaModel,
						)

if is_vision_available():
						from PIL import Image

						from transformers import LayoutLMvaImageProcessor



class   UpperCAmelCase_    :







							def __init__(   self,			__a,			__a=2,			__a=3,			__a=4,			__a=2,			__a=7,			__a=True,			__a=True,			__a=True,			__a=True,			__a=99,			__a=36,			__a=2,			__a=4,			__a=37,			__a="gelu",			__a=0.1,			__a=0.1,			__a=512,			__a=16,			__a=2,			__a=0.02,			__a=6,			__a=6,			__a=3,			__a=4,			__a=None,			__a=1000,			):

														'''simple docstring'''

														_lowerCAmelCase     :							Dict    =    parent
														_lowerCAmelCase     :							str    =    batch_size
														_lowerCAmelCase     :							List[Any]    =    num_channels
														_lowerCAmelCase     :							List[Any]    =    image_size
														_lowerCAmelCase     :							Dict    =    patch_size
														_lowerCAmelCase     :							List[Any]    =    is_training
														_lowerCAmelCase     :							Optional[Any]    =    use_input_mask
														_lowerCAmelCase     :							Union[str, Any]    =    use_token_type_ids
														_lowerCAmelCase     :							Optional[Any]    =    use_labels
														_lowerCAmelCase     :							Union[str, Any]    =    vocab_size
														_lowerCAmelCase     :							Tuple    =    hidden_size
														_lowerCAmelCase     :							Any    =    num_hidden_layers
														_lowerCAmelCase     :							Dict    =    num_attention_heads
														_lowerCAmelCase     :							List[str]    =    intermediate_size
														_lowerCAmelCase     :							Tuple    =    hidden_act
														_lowerCAmelCase     :							Tuple    =    hidden_dropout_prob
														_lowerCAmelCase     :							Dict    =    attention_probs_dropout_prob
														_lowerCAmelCase     :							Optional[int]    =    max_position_embeddings
														_lowerCAmelCase     :							Optional[Any]    =    type_vocab_size
														_lowerCAmelCase     :							str    =    type_sequence_label_size
														_lowerCAmelCase     :							Optional[Any]    =    initializer_range
														_lowerCAmelCase     :							Tuple    =    coordinate_size
														_lowerCAmelCase     :							Tuple    =    shape_size
														_lowerCAmelCase     :							int    =    num_labels
														_lowerCAmelCase     :							List[str]    =    num_choices
														_lowerCAmelCase     :							Union[str, Any]    =    scope
														_lowerCAmelCase     :							Tuple    =    range_bbox

														# LayoutLMv3's sequence length equals the number of text tokens + number of patches + 1 (we add 1 for the CLS token)
														_lowerCAmelCase     :							int    =    text_seq_length
														_lowerCAmelCase     :							Dict    =    (image_size // patch_size) ** 2 + 1
														_lowerCAmelCase     :							int    =    self.text_seq_length + self.image_seq_length







							def    snake_case__      (   self):

														'''simple docstring'''

														_lowerCAmelCase     :							int    =    ids_tensor([self.batch_size, self.text_seq_length],			self.vocab_size)

														_lowerCAmelCase     :							Union[str, Any]    =    ids_tensor([self.batch_size, self.text_seq_length, 4],			self.range_bbox)
														_lowerCAmelCase     :							Optional[Any]    =    bbox.numpy()
														# Ensure that bbox is legal
														for i in range(bbox.shape[0]):
																					for j in range(bbox.shape[1]):
																												if bbox[i, j, 3] < bbox[i, j, 1]:
																																			_lowerCAmelCase     :							Dict    =    bbox[i, j, 3]
																																			_lowerCAmelCase     :							Any    =    bbox[i, j, 1]
																																			_lowerCAmelCase     :							Union[str, Any]    =    tmp_coordinate
																												if bbox[i, j, 2] < bbox[i, j, 0]:
																																			_lowerCAmelCase     :							Optional[Any]    =    bbox[i, j, 2]
																																			_lowerCAmelCase     :							str    =    bbox[i, j, 0]
																																			_lowerCAmelCase     :							Any    =    tmp_coordinate
														_lowerCAmelCase     :							str    =    tf.constant(__a)

														_lowerCAmelCase     :							Any    =    floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size])

														_lowerCAmelCase     :							Dict    =    None
														if self.use_input_mask:
																					_lowerCAmelCase     :							Optional[Any]    =    random_attention_mask([self.batch_size, self.text_seq_length])

														_lowerCAmelCase     :							Any    =    None
														if self.use_token_type_ids:
																					_lowerCAmelCase     :							Any    =    ids_tensor([self.batch_size, self.text_seq_length],			self.type_vocab_size)

														_lowerCAmelCase     :							str    =    None
														_lowerCAmelCase     :							Optional[int]    =    None
														if self.use_labels:
																					_lowerCAmelCase     :							str    =    ids_tensor([self.batch_size],			self.type_sequence_label_size)
																					_lowerCAmelCase     :							List[str]    =    ids_tensor([self.batch_size, self.text_seq_length],			self.num_labels)

														_lowerCAmelCase     :							str    =    LayoutLMvaConfig(
														    vocab_size=self.vocab_size,			hidden_size=self.hidden_size,			num_hidden_layers=self.num_hidden_layers,			num_attention_heads=self.num_attention_heads,			intermediate_size=self.intermediate_size,			hidden_act=self.hidden_act,			hidden_dropout_prob=self.hidden_dropout_prob,			attention_probs_dropout_prob=self.attention_probs_dropout_prob,			max_position_embeddings=self.max_position_embeddings,			type_vocab_size=self.type_vocab_size,			initializer_range=self.initializer_range,			coordinate_size=self.coordinate_size,			shape_size=self.shape_size,			input_size=self.image_size,			patch_size=self.patch_size,			)

														return config, input_ids, bbox, pixel_values, token_type_ids, input_mask, sequence_labels, token_labels







							def    snake_case__      (   self,			__a,			__a,			__a,			__a,			__a,			__a):

														'''simple docstring'''

														_lowerCAmelCase     :							Optional[Any]    =    TFLayoutLMvaModel(config=__a)

														# text + image
														_lowerCAmelCase     :							List[Any]    =    model(__a,			pixel_values=__a,			training=__a)
														_lowerCAmelCase     :							Any    =    model(
														    __a,			bbox=__a,			pixel_values=__a,			attention_mask=__a,			token_type_ids=__a,			training=__a,			)
														_lowerCAmelCase     :							int    =    model(__a,			bbox=__a,			pixel_values=__a,			training=__a)

														self.parent.assertEqual(result.last_hidden_state.shape,			(self.batch_size, self.seq_length, self.hidden_size))

														# text only
														_lowerCAmelCase     :							Optional[int]    =    model(__a,			training=__a)
														self.parent.assertEqual(
														    result.last_hidden_state.shape,			(self.batch_size, self.text_seq_length, self.hidden_size))

														# image only
														_lowerCAmelCase     :							Union[str, Any]    =    model({"pixel_values": pixel_values},			training=__a)
														self.parent.assertEqual(
														    result.last_hidden_state.shape,			(self.batch_size, self.image_seq_length, self.hidden_size))







							def    snake_case__      (   self,			__a,			__a,			__a,			__a,			__a,			__a,			__a):

														'''simple docstring'''

														_lowerCAmelCase     :							int    =    self.num_labels
														_lowerCAmelCase     :							int    =    TFLayoutLMvaForSequenceClassification(config=__a)
														_lowerCAmelCase     :							Optional[Any]    =    model(
														    __a,			bbox=__a,			pixel_values=__a,			attention_mask=__a,			token_type_ids=__a,			labels=__a,			training=__a,			)
														self.parent.assertEqual(result.logits.shape,			(self.batch_size, self.num_labels))







							def    snake_case__      (   self,			__a,			__a,			__a,			__a,			__a,			__a,			__a):

														'''simple docstring'''

														_lowerCAmelCase     :							Dict    =    self.num_labels
														_lowerCAmelCase     :							str    =    TFLayoutLMvaForTokenClassification(config=__a)
														_lowerCAmelCase     :							Optional[Any]    =    model(
														    __a,			bbox=__a,			pixel_values=__a,			attention_mask=__a,			token_type_ids=__a,			labels=__a,			training=__a,			)
														self.parent.assertEqual(result.logits.shape,			(self.batch_size, self.text_seq_length, self.num_labels))







							def    snake_case__      (   self,			__a,			__a,			__a,			__a,			__a,			__a,			__a):

														'''simple docstring'''

														_lowerCAmelCase     :							str    =    2
														_lowerCAmelCase     :							Tuple    =    TFLayoutLMvaForQuestionAnswering(config=__a)
														_lowerCAmelCase     :							List[Any]    =    model(
														    __a,			bbox=__a,			pixel_values=__a,			attention_mask=__a,			token_type_ids=__a,			start_positions=__a,			end_positions=__a,			training=__a,			)
														self.parent.assertEqual(result.start_logits.shape,			(self.batch_size, self.seq_length))
														self.parent.assertEqual(result.end_logits.shape,			(self.batch_size, self.seq_length))







							def    snake_case__      (   self):

														'''simple docstring'''

														_lowerCAmelCase     :							Any    =    self.prepare_config_and_inputs()
														((_lowerCAmelCase)   ,    (_lowerCAmelCase)   ,    (_lowerCAmelCase)   ,    (_lowerCAmelCase)   ,    (_lowerCAmelCase)   ,    (_lowerCAmelCase)   ,    (_lowerCAmelCase)   ,    (_lowerCAmelCase))     :							Any    =    config_and_inputs
														_lowerCAmelCase     :							str    =    {
														    "input_ids": input_ids,
														    "bbox": bbox,
														    "pixel_values": pixel_values,
														    "token_type_ids": token_type_ids,
														    "attention_mask": input_mask,
														}
														return config, inputs_dict



@require_tf
class   UpperCAmelCase_    (       a   ,					a   ,					unittest.TestCase):
							lowerCamelCase__   			=		(
							    (
							        TFLayoutLMvaModel,
							        TFLayoutLMvaForQuestionAnswering,
							        TFLayoutLMvaForSequenceClassification,
							        TFLayoutLMvaForTokenClassification,
							    )
							    if is_tf_available()
							    else ()
							)
							lowerCamelCase__   			=		(
							    {'document-question-answering': TFLayoutLMvaForQuestionAnswering, 'feature-extraction': TFLayoutLMvaModel}
							    if is_tf_available()
							    else {}
							)

							lowerCamelCase__   			=		False
							lowerCamelCase__   			=		False
							lowerCamelCase__   			=		False







							def    snake_case__      (   self,			__a,			__a,			__a,			__a,			__a):

														'''simple docstring'''

														return True







							def    snake_case__      (   self,			__a,			__a,			__a=False):

														'''simple docstring'''

														_lowerCAmelCase     :							Any    =    copy.deepcopy(__a)

														if model_class in get_values(__a):
																					_lowerCAmelCase     :							Any    =    {
																					    k: tf.tile(tf.expand_dims(__a,			1),			(1, self.model_tester.num_choices) + (1,) * (v.ndim - 1))
																					    if isinstance(__a,			tf.Tensor) and v.ndim > 0
																					    else v
																					    for k, v in inputs_dict.items()
																					}

														if return_labels:
																					if model_class in get_values(__a):
																												_lowerCAmelCase     :							Any    =    tf.ones(self.model_tester.batch_size,			dtype=tf.intaa)
																					elif model_class in get_values(__a):
																												_lowerCAmelCase     :							Any    =    tf.zeros(self.model_tester.batch_size,			dtype=tf.intaa)
																												_lowerCAmelCase     :							Tuple    =    tf.zeros(self.model_tester.batch_size,			dtype=tf.intaa)
																					elif model_class in get_values(__a):
																												_lowerCAmelCase     :							Any    =    tf.zeros(self.model_tester.batch_size,			dtype=tf.intaa)
																					elif model_class in get_values(__a):
																												_lowerCAmelCase     :							Union[str, Any]    =    tf.zeros(
																												    (self.model_tester.batch_size, self.model_tester.text_seq_length),			dtype=tf.intaa)

														return inputs_dict







							def    snake_case__      (   self):

														'''simple docstring'''

														_lowerCAmelCase     :							Dict    =    TFLayoutLMvaModelTester(self)
														_lowerCAmelCase     :							Dict    =    ConfigTester(self,			config_class=__a,			hidden_size=37)







							def    snake_case__      (   self):

														'''simple docstring'''

														self.config_tester.run_common_tests()







							def    snake_case__      (   self):

														'''simple docstring'''

														_lowerCAmelCase   ,    _lowerCAmelCase     :							Optional[int]    =    self.model_tester.prepare_config_and_inputs_for_common()
														for model_class in self.all_model_classes:
																					_lowerCAmelCase     :							List[str]    =    model_class(__a)
																					if getattr(__a,			"hf_compute_loss",			__a):
																												# The number of elements in the loss should be the same as the number of elements in the label
																												_lowerCAmelCase     :							int    =    self._prepare_for_class(inputs_dict.copy(),			__a,			return_labels=__a)
																												_lowerCAmelCase     :							int    =    prepared_for_class[
																												    sorted(prepared_for_class.keys() - inputs_dict.keys(),			reverse=__a)[0]
																												]
																												_lowerCAmelCase     :							str    =    added_label.shape.as_list()[:1]

																												# Test that model correctly compute the loss with kwargs
																												_lowerCAmelCase     :							str    =    self._prepare_for_class(inputs_dict.copy(),			__a,			return_labels=__a)
																												_lowerCAmelCase     :							Optional[int]    =    prepared_for_class.pop("input_ids")

																												_lowerCAmelCase     :							Optional[int]    =    model(__a,			**__a)[0]
																												self.assertTrue(loss.shape.as_list() == expected_loss_size or loss.shape.as_list() == [1])

																												# Test that model correctly compute the loss when we mask some positions
																												_lowerCAmelCase     :							Optional[int]    =    self._prepare_for_class(inputs_dict.copy(),			__a,			return_labels=__a)
																												_lowerCAmelCase     :							Union[str, Any]    =    prepared_for_class.pop("input_ids")
																												if "labels" in prepared_for_class:
																																			_lowerCAmelCase     :							List[str]    =    prepared_for_class["labels"].numpy()
																																			if len(labels.shape) > 1 and labels.shape[1] != 1:
																																										_lowerCAmelCase     :							Optional[int]    =    -100
																																										_lowerCAmelCase     :							Optional[Any]    =    tf.convert_to_tensor(__a)
																																										_lowerCAmelCase     :							Any    =    model(__a,			**__a)[0]
																																										self.assertTrue(loss.shape.as_list() == expected_loss_size or loss.shape.as_list() == [1])
																																										self.assertTrue(not np.any(np.isnan(loss.numpy())))

                # Test that model correctly compute the loss with a dict
																												_lowerCAmelCase     :							Tuple    =    self._prepare_for_class(inputs_dict.copy(),			__a,			return_labels=__a)
																												_lowerCAmelCase     :							Optional[int]    =    model(__a)[0]
																												self.assertTrue(loss.shape.as_list() == expected_loss_size or loss.shape.as_list() == [1])

																												# Test that model correctly compute the loss with a tuple
																												_lowerCAmelCase     :							Tuple    =    self._prepare_for_class(inputs_dict.copy(),			__a,			return_labels=__a)

																												# Get keys that were added with the _prepare_for_class function
																												_lowerCAmelCase     :							int    =    prepared_for_class.keys() - inputs_dict.keys()
																												_lowerCAmelCase     :							str    =    inspect.signature(model.call).parameters
																												_lowerCAmelCase     :							int    =    list(signature.keys())

																												# Create a dictionary holding the location of the tensors in the tuple
																												_lowerCAmelCase     :							Optional[int]    =    {0: "input_ids"}
																												for label_key in label_keys:
																																			_lowerCAmelCase     :							str    =    signature_names.index(__a)
																																			_lowerCAmelCase     :							Dict    =    label_key
																												_lowerCAmelCase     :							Optional[int]    =    sorted(tuple_index_mapping.items())
																												# Initialize a list with their default values, update the values and convert to a tuple
																												_lowerCAmelCase     :							Any    =    []

																												for name in signature_names:
																																			if name != "kwargs":
																																										list_input.append(signature[name].default)

																												for index, value in sorted_tuple_index_mapping:
																																			_lowerCAmelCase     :							Optional[Any]    =    prepared_for_class[value]

																												_lowerCAmelCase     :							Union[str, Any]    =    tuple(__a)

																												# Send to model
																												_lowerCAmelCase     :							str    =    model(tuple_input[:-1])[0]

																												self.assertTrue(loss.shape.as_list() == expected_loss_size or loss.shape.as_list() == [1])







							def    snake_case__      (   self):

														'''simple docstring'''

														(
														    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    
														)     :							Dict    =    self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_model(__a,			__a,			__a,			__a,			__a,			__a)







							def    snake_case__      (   self):

														'''simple docstring'''

														(
														    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    
														)     :							Union[str, Any]    =    self.model_tester.prepare_config_and_inputs()
														for type in ["absolute", "relative_key", "relative_key_query"]:
																					_lowerCAmelCase     :							List[str]    =    type
																					self.model_tester.create_and_check_model(__a,			__a,			__a,			__a,			__a,			__a)







							def    snake_case__      (   self):

														'''simple docstring'''

														(
														    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    
														)     :							Dict    =    self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_for_sequence_classification(
														    __a,			__a,			__a,			__a,			__a,			__a,			__a)







							def    snake_case__      (   self):

														'''simple docstring'''

														(
														    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    
														)     :							int    =    self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_for_token_classification(
														    __a,			__a,			__a,			__a,			__a,			__a,			__a)







							def    snake_case__      (   self):

														'''simple docstring'''

														(
														    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    (
														    _lowerCAmelCase
														)   ,    
														)     :							List[Any]    =    self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_for_question_answering(
														    __a,			__a,			__a,			__a,			__a,			__a,			__a)







							@slow
							def    snake_case__      (   self):

														'''simple docstring'''

														for model_name in TF_LAYOUTLMV3_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																					_lowerCAmelCase     :							str    =    TFLayoutLMvaModel.from_pretrained(__a)
																					self.assertIsNotNone(__a)






def 				A				(					):





							'''simple docstring'''




							_lowerCAmelCase     :							Any    =    Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"  )
							return image



@require_tf
class   UpperCAmelCase_    (       unittest.TestCase):







							@cached_property
							def    snake_case__      (   self):

														'''simple docstring'''

														return LayoutLMvaImageProcessor(apply_ocr=__a) if is_vision_available() else None







							@slow
							def    snake_case__      (   self):

														'''simple docstring'''

														_lowerCAmelCase     :							List[str]    =    TFLayoutLMvaModel.from_pretrained("microsoft/layoutlmv3-base")

														_lowerCAmelCase     :							str    =    self.default_image_processor
														_lowerCAmelCase     :							List[Any]    =    prepare_img()
														_lowerCAmelCase     :							Union[str, Any]    =    image_processor(images=__a,			return_tensors="tf").pixel_values

														_lowerCAmelCase     :							List[str]    =    tf.constant([[1, 2]])
														_lowerCAmelCase     :							Any    =    tf.expand_dims(tf.constant([[1, 2, 3, 4], [5, 6, 7, 8]]),			axis=0)

														# forward pass
														_lowerCAmelCase     :							Optional[Any]    =    model(input_ids=__a,			bbox=__a,			pixel_values=__a,			training=__a)

														# verify the logits
														_lowerCAmelCase     :							Any    =    (1, 199, 768)
														self.assertEqual(outputs.last_hidden_state.shape,			__a)

														_lowerCAmelCase     :							List[Any]    =    tf.constant(
														    [[-0.0_529, 0.3_618, 0.1_632], [-0.1_587, -0.1_667, -0.0_400], [-0.1_557, -0.1_671, -0.0_505]])

														self.assertTrue(np.allclose(outputs.last_hidden_state[0, :3, :3],			__a,			atol=1E-4))


"""simple docstring"""




def   __magic_name__	(      __snake_case				:       list  ) ->				list:

       if len(__snake_case  ) < 2:
              return collection

       def circle_sort_util(__snake_case				:       list     , __snake_case				:       int     , __snake_case				:       int  ) -> bool:
              lowercase    :				List[Any]       		=							False

              if low == high:
                     return swapped

              lowercase    :				Union[str, Any]       		=							low
              lowercase    :				str       		=							high

              while left < right:
                     if collection[left] > collection[right]:
                            lowercase		,    lowercase    :				Optional[Any]       		=							(
                                collection[right],
                                collection[left],
                            )
                            lowercase    :				Tuple       		=							True

                     left += 1
                     right -= 1

              if left == right and collection[left] > collection[right + 1]:
                     lowercase		,    lowercase    :				str       		=							(
                         collection[right + 1],
                         collection[left],
                     )

                     lowercase    :				Union[str, Any]       		=							True

              lowercase    :				Any       		=							low + int((high - low) / 2  )
              lowercase    :				Tuple       		=							circle_sort_util(__snake_case     , __snake_case     , __snake_case  )
              lowercase    :				List[Any]       		=							circle_sort_util(__snake_case     , mid + 1     , __snake_case  )

              return swapped or left_swap or right_swap

       lowercase    :				int       		=							True

       while is_not_sorted is True:
              lowercase    :				int       		=							circle_sort_util(__snake_case     , 0     , len(__snake_case  ) - 1  )

       return collection


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


