




import json
import os
import unittest

from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES, XLMTokenizer
from transformers.testing_utils import slow

from ...test_tokenization_common import TokenizerTesterMixin




class       _A				(		__lowercase       ,     unittest.TestCase     ):
		__a					    =       XLMTokenizer
		__a					    =       False






		def 				UpperCAmelCase (    self			):
								super().setUp()

								# Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt
								_UpperCAmelCase      =			[
								    """l""",
								    """o""",
								    """w""",
								    """e""",
								    """r""",
								    """s""",
								    """t""",
								    """i""",
								    """d""",
								    """n""",
								    """w</w>""",
								    """r</w>""",
								    """t</w>""",
								    """lo""",
								    """low""",
								    """er</w>""",
								    """low</w>""",
								    """lowest</w>""",
								    """newer</w>""",
								    """wider</w>""",
								    """<unk>""",
								]
								_UpperCAmelCase      =			dict(zip(_SCREAMING_SNAKE_CASE						,		range(len(_SCREAMING_SNAKE_CASE			)			)			)			)
								_UpperCAmelCase      =			["""l o 123""", """lo w 1456""", """e r</w> 1789""", """"""]

								_UpperCAmelCase      =			os.path.join(self.tmpdirname						,		VOCAB_FILES_NAMES["""vocab_file"""]			)
								_UpperCAmelCase      =			os.path.join(self.tmpdirname						,		VOCAB_FILES_NAMES["""merges_file"""]			)
								with open(self.vocab_file						,		"""w"""			) as fp:
														fp.write(json.dumps(_SCREAMING_SNAKE_CASE			)			)
								with open(self.merges_file						,		"""w"""			) as fp:
														fp.write("""\n""".join(_SCREAMING_SNAKE_CASE			)			)






		def 				UpperCAmelCase (    self						,		_SCREAMING_SNAKE_CASE			):
								_UpperCAmelCase      =			"""lower newer"""
								_UpperCAmelCase      =			"""lower newer"""
								return input_text, output_text






		def 				UpperCAmelCase (    self			):
								_UpperCAmelCase      =			XLMTokenizer(self.vocab_file						,		self.merges_file			)

								_UpperCAmelCase      =			"""lower"""
								_UpperCAmelCase      =			["""low""", """er</w>"""]
								_UpperCAmelCase      =			tokenizer.tokenize(_SCREAMING_SNAKE_CASE			)
								self.assertListEqual(_SCREAMING_SNAKE_CASE						,		_SCREAMING_SNAKE_CASE			)

								_UpperCAmelCase      =			tokens + ["""<unk>"""]
								_UpperCAmelCase      =			[14, 15, 20]
								self.assertListEqual(tokenizer.convert_tokens_to_ids(_SCREAMING_SNAKE_CASE			)						,		_SCREAMING_SNAKE_CASE			)






		@slow
		def 				UpperCAmelCase (    self			):
								_UpperCAmelCase      =			XLMTokenizer.from_pretrained("""xlm-mlm-en-2048"""			)

								_UpperCAmelCase      =			tokenizer.encode("""sequence builders"""						,		add_special_tokens=_SCREAMING_SNAKE_CASE			)
								_UpperCAmelCase      =			tokenizer.encode("""multi-sequence build"""						,		add_special_tokens=_SCREAMING_SNAKE_CASE			)

								_UpperCAmelCase      =			tokenizer.build_inputs_with_special_tokens(_SCREAMING_SNAKE_CASE			)
								_UpperCAmelCase      =			tokenizer.build_inputs_with_special_tokens(_SCREAMING_SNAKE_CASE						,		_SCREAMING_SNAKE_CASE			)

								assert encoded_sentence == [0] + text + [1]
								assert encoded_pair == [0] + text + [1] + text_a + [1]





from __future__ import annotations




def        _SCREAMING_SNAKE_CASE      (		snake_case			,     snake_case       )						->				float:
						_UpperCAmelCase      =			sorted(numsa + numsa       )
						_UpperCAmelCase    ,					_UpperCAmelCase      =			divmod(len(snake_case       )			,     2       )
						if mod == 1:
												return all_numbers[div]
						else:
												return (all_numbers[div] + all_numbers[div - 1]) / 2


if __name__ == "__main__":
				import doctest

				doctest.testmod()
				a													=			[float(x) for x in input("Enter the elements of first array: ").split()]
				a													=			[float(x) for x in input("Enter the elements of second array: ").split()]
				print(F'The median of two arrays is: {median_of_two_arrays(array_a, array_a)}')