






"""simple docstring"""


from __future__ import annotations


def 					UpperCAmelCase			(				a__    ,			a__   ):





						'''simple docstring'''






						lowerCAmelCase      :Any				  = 0
						lowerCAmelCase      :Optional[int]				  = len(a__   ) - 1
						while left <= right:
												lowerCAmelCase      :Optional[int]				  = (left + right) // 2
												if left == right:
																		if sorted_list[middle] < item:
																								lowerCAmelCase      :Optional[int]				  = middle + 1
																		break
												elif sorted_list[middle] < item:
																		lowerCAmelCase      :str				  = middle + 1
												else:
																		lowerCAmelCase      :int				  = middle - 1
						sorted_list.insert(a__    ,			a__   )
						return sorted_list


def 					UpperCAmelCase			(				a__    ,			a__   ):





						'''simple docstring'''






						lowerCAmelCase      :Dict				  = []
						while left and right:
												if left[0][0] < right[0][0]:
																		result.append(left.pop(0   )   )
												else:
																		result.append(right.pop(0   )   )
						return result + left + right


def 					UpperCAmelCase			(				a__   ):





						'''simple docstring'''






						lowerCAmelCase      :Tuple				  = len(a__   )
						if length <= 1:
												return list_ad
						lowerCAmelCase      :Optional[int]				  = length // 2
						return merge(sortlist_ad(list_ad[:middle]   )    ,			sortlist_ad(list_ad[middle:]   )   )


def 					UpperCAmelCase			(				a__   ):





						'''simple docstring'''






						if len(a__   ) <= 1:
												return collection
						lowerCAmelCase      :List[str]				  = []
						lowerCAmelCase      :Tuple				  = False
						for i in range(0    ,			len(a__   )    ,			2   ):
												if i == len(a__   ) - 1:
																		lowerCAmelCase      :List[str]				  = True
												else:
																		if collection[i] < collection[i + 1]:
																								two_paired_list.append([collection[i], collection[i + 1]]   )
																		else:
																								two_paired_list.append([collection[i + 1], collection[i]]   )
						lowerCAmelCase      :Tuple				  = sortlist_ad(a__   )
						lowerCAmelCase      :int				  = [i[0] for i in sorted_list_ad]
						result.append(sorted_list_ad[-1][1]   )
						if has_last_odd_item:
												lowerCAmelCase      :Any				  = collection[-1]
												lowerCAmelCase      :Tuple				  = binary_search_insertion(a__    ,			a__   )
						lowerCAmelCase      :Any				  = False
						for i in range(len(a__   ) - 1   ):
												if result[i] == collection[-1] and has_last_odd_item:
																		lowerCAmelCase      :Tuple				  = True
												lowerCAmelCase      :str				  = sorted_list_ad[i][1]
												# If last_odd_item is inserted before the item's index,
												# you should forward index one more.
												if is_last_odd_item_inserted_before_this_index:
																		lowerCAmelCase      :str				  = result[: i + 2] + binary_search_insertion(result[i + 2 :]    ,			a__   )
												else:
																		lowerCAmelCase      :Tuple				  = result[: i + 1] + binary_search_insertion(result[i + 1 :]    ,			a__   )

						return result


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







"""simple docstring"""


import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_torch, slow, torch_device


if is_torch_available():
		import torch

		from transformers import XLMProphetNetForConditionalGeneration, XLMProphetNetTokenizer




@require_torch
class 	__UpperCamelCase    (    unittest.TestCase	):
					@slow
					def 					UpperCAmelCase__   (       self       :  Tuple      )  ->					Union[str, Any]:
											lowerCAmelCase      :Any				  = XLMProphetNetForConditionalGeneration.from_pretrained('microsoft/xprophetnet-large-wiki100-cased'      )
											model.to(UpperCAmelCase      )

											# encoder-decoder outputs
											lowerCAmelCase      :Any				  = torch.tensor([[17, 9_6208, 10_3471, 2]]      ).to(UpperCAmelCase      )
											lowerCAmelCase      :Optional[int]				  = torch.tensor(
											    [[2, 250, 9953, 34, 6_9489, 1620, 32, 11_8424, 624, 210, 105, 2913, 1032, 351]]      ).to(UpperCAmelCase      )
											lowerCAmelCase      :Tuple				  = model(
											    input_ids=UpperCAmelCase    ,   attention_mask=UpperCAmelCase    ,   encoder_outputs=UpperCAmelCase    ,   decoder_input_ids=UpperCAmelCase      )
											lowerCAmelCase      :Tuple				  = output[0]
											lowerCAmelCase      :Any				  = torch.Size((1, 14, 25_0012)      )
											self.assertEqual(output_predited_logis.shape    ,   UpperCAmelCase      )
											lowerCAmelCase      :Optional[int]				  = torch.tensor(
											    [[[-6.3_9_8_6, -8.2_3_9_1, 1_2.5_1_8_9], [-6.3_2_8_9, -8.0_8_6_4, 1_2.6_2_1_1], [-6.2_4_1_8, -8.0_4_4_5, 1_2.7_9_6_8]]]      ).to(UpperCAmelCase      )
											self.assertTrue(torch.allclose(output_predited_logis[:, :3, :3]    ,   UpperCAmelCase    ,   atol=1e-4      )      )

											# encoder outputs
											lowerCAmelCase      :int				  = model.prophetnet.encoder(UpperCAmelCase      )[0]
											lowerCAmelCase      :int				  = torch.tensor(
											    [[[-1.4_2_6_0, -0.7_6_2_8, 0.8_4_5_3], [-1.4_7_1_9, -0.1_3_9_1, 0.7_8_0_7], [-1.7_6_7_8, 0.0_1_1_4, 0.4_6_4_6]]]      ).to(UpperCAmelCase      )
											lowerCAmelCase      :Optional[Any]				  = torch.Size((1, 4, 1024)      )
											self.assertEqual(encoder_outputs.shape    ,   UpperCAmelCase      )
											self.assertTrue(torch.allclose(encoder_outputs[:, :3, :3]    ,   UpperCAmelCase    ,   atol=1e-4      )      )

											# decoder outputs
											lowerCAmelCase      :Tuple				  = model.prophetnet.decoder(
											    UpperCAmelCase    ,   encoder_hidden_states=UpperCAmelCase    ,   )
											lowerCAmelCase      :Optional[Any]				  = decoder_outputs[1].view(1    ,   model.config.ngram    ,   14    ,   -1      )
											lowerCAmelCase      :Any				  = model.lm_head(UpperCAmelCase      )
											lowerCAmelCase      :Optional[int]				  = predicting_streams_logits[:, 0]
											self.assertTrue(torch.allclose(next_first_stream_logits[:, :3, :3]    ,   UpperCAmelCase    ,   atol=1e-4      )      )
					@slow
					def 					UpperCAmelCase__   (       self       :  List[Any]      )  ->					Optional[Any]:
											lowerCAmelCase      :Union[str, Any]				  = XLMProphetNetForConditionalGeneration.from_pretrained(
											    'microsoft/xprophetnet-large-wiki100-cased-xglue-ntg'      )
											model.to(UpperCAmelCase      )

											lowerCAmelCase      :Tuple				  = torch.tensor([[17, 9_6208, 10_3471, 2]]      ).to(UpperCAmelCase      )
											lowerCAmelCase      :Any				  = torch.tensor(
											    [[2, 250, 9953, 34, 6_9489, 1620, 32, 11_8424, 624, 210, 105, 2913, 1032, 351]]      ).to(UpperCAmelCase      )
											lowerCAmelCase      :Tuple				  = model(
											    input_ids=UpperCAmelCase    ,   attention_mask=UpperCAmelCase    ,   encoder_outputs=UpperCAmelCase    ,   decoder_input_ids=UpperCAmelCase      )
											lowerCAmelCase      :Dict				  = output[0]
											lowerCAmelCase      :List[str]				  = torch.Size((1, 14, 25_0012)      )
											self.assertEqual(output_predited_logis.shape    ,   UpperCAmelCase      )
											# compare the actual values for a slice.
											lowerCAmelCase      :List[Any]				  = torch.tensor(
											    [[[-9.2_2_5_3, -9.7_1_7_3, -6.3_5_2_9], [-7.6_7_0_1, -9.0_1_4_5, -1.9_3_8_2], [-8.0_1_9_5, -7.0_0_0_4, -0.1_5_2_3]]]      ).to(UpperCAmelCase      )

											self.assertTrue(torch.allclose(output_predited_logis[:, :3, :3]    ,   UpperCAmelCase    ,   atol=1e-4      )      )
					@slow
					def 					UpperCAmelCase__   (       self       :  Optional[Any]      )  ->					Optional[int]:
											lowerCAmelCase      :str				  = XLMProphetNetForConditionalGeneration.from_pretrained(
											    'microsoft/xprophetnet-large-wiki100-cased-xglue-ntg'      )
											model.to(UpperCAmelCase      )
											lowerCAmelCase      :Any				  = 512

											lowerCAmelCase      :Union[str, Any]				  = XLMProphetNetTokenizer.from_pretrained('microsoft/xprophetnet-large-wiki100-cased-xglue-ntg'      )

											lowerCAmelCase      :Optional[int]				  = (
											    'Microsoft Corporation intends to officially end free support for the Windows 7 operating system after'
											    ' January 14, 2020, according to the official portal of the organization. From that day, users of this'
											    ' system will not be able to receive security updates, which could make their computers vulnerable to'
											    ' cyber attacks.'
											)
											lowerCAmelCase      :Union[str, Any]				  = (
											    'орпорация Microsoft намерена официально прекратить бесплатную поддержку операционной системы Windows 7'
											    ' после 14 января 2020 года, сообщается на официальном портале организации . С указанного дня пользователи'
											    ' этой системы не смогут получать обновления безопасности, из-за чего их компьютеры могут стать уязвимыми'
											    ' к кибератакам.'
											)
											lowerCAmelCase      :Optional[Any]				  = (
											    '根据该组织的官方门户网站，微软公司打算在2020年1月14日之后正式终止对Windows 7操作系统的免费支持。从那时起，该系统的用户将无法接收安全更新，这可能会使他们的计算机容易受到网络攻击。'
											)

											lowerCAmelCase      :List[Any]				  = tokenizer(
											    [EN_SENTENCE, RU_SENTENCE, ZH_SENTENCE]    ,   padding=UpperCAmelCase    ,   max_length=255    ,   return_tensors='pt'      ).input_ids
											lowerCAmelCase      :List[str]				  = input_ids.to(UpperCAmelCase      )

											lowerCAmelCase      :Dict				  = model.generate(
											    UpperCAmelCase    ,   num_beams=10    ,   length_penalty=1.0    ,   no_repeat_ngram_size=3    ,   early_stopping=UpperCAmelCase      )
											lowerCAmelCase      :str				  = [tokenizer.decode(UpperCAmelCase    ,   skip_special_tokens=UpperCAmelCase      ) for g in summary_ids]
											lowerCAmelCase      :Dict				  = 'Microsoft to end Windows 7 free support after January 14, 2020'
											lowerCAmelCase      :Tuple				  = 'Microsoft намерена прекратить бесплатную поддержку Windows 7 после 14 января 2020 года'
											lowerCAmelCase      :Any				  = '微软打算终止对Windows 7操作系统的免费支持'
											self.assertListEqual(
											    [EXPECTED_TITLE_EN, EXPECTED_TITLE_RU, EXPECTED_TITLE_ZH]    ,   UpperCAmelCase    ,   )

											lowerCAmelCase      :List[str]				  = model.generate(
											    UpperCAmelCase    ,   num_beams=1    ,   length_penalty=1.0    ,   no_repeat_ngram_size=3    ,   early_stopping=UpperCAmelCase      )
											lowerCAmelCase      :Dict				  = [
											    tokenizer.convert_ids_to_tokens(UpperCAmelCase    ,   skip_special_tokens=UpperCAmelCase      ) for g in summary_ids_beama
											]
											lowerCAmelCase      :Optional[Any]				  = '▁Microsoft ▁to ▁end ▁free ▁support ▁for ▁Windows ▁7'.split(' '      )
											lowerCAmelCase      :Optional[int]				  = '▁Microsoft ▁намерен а ▁прекрати ть ▁бес плат ную ▁поддержку ▁Windows ▁7 ▁после ▁14 ▁января ▁2020 ▁года'.split(
											    ' '      )
											lowerCAmelCase      :Optional[Any]				  = '微软 公司 打算 终止 对 Windows ▁7 操作 系统的 免费 支持'.split(' '      )
											self.assertListEqual(
											    [EXPECTED_TITLE_EN_BEAM1_TOK, EXPECTED_TITLE_RU_BEAM1_TOK, EXPECTED_TITLE_ZH_BEAM1_TOK]    ,   UpperCAmelCase    ,   )