

"""simple docstring"""







import os
import unittest

from transformers.models.transfo_xl.tokenization_transfo_xl import VOCAB_FILES_NAMES, TransfoXLTokenizer

from ...test_tokenization_common import TokenizerTesterMixin

class 		UpperCamelCase      (   __A				,     unittest.TestCase						):
				UpperCAmelCase    :				Dict   =		TransfoXLTokenizer
				UpperCAmelCase    :				Tuple   =		False
				UpperCAmelCase    :				Optional[Any]   =		False



				def  _lowercase					(self    :				str)   ->     Optional[Any]:
					super().setUp()

					__snake_case      :							Any						=			[
					    '<unk>',
					    '[CLS]',
					    '[SEP]',
					    'want',
					    'unwanted',
					    'wa',
					    'un',
					    'running',
					    ',',
					    'low',
					    'l',
					]
					__snake_case      :							Union[str, Any]						=			os.path.join(self.tmpdirname     ,  VOCAB_FILES_NAMES['vocab_file'])
					with open(self.vocab_file     ,  'w'     ,  encoding='utf-8') as vocab_writer:
						vocab_writer.write(''.join([x + '\n' for x in vocab_tokens]))



				def  _lowercase					(self    :				Dict     ,  **_A    :				Optional[Any])   ->     List[str]:
					__snake_case      :							Union[str, Any]						=			True
					return TransfoXLTokenizer.from_pretrained(self.tmpdirname     ,  **__lowercase)



				def  _lowercase					(self    :				Optional[Any]     ,  _A    :				Dict)   ->     Optional[Any]:
					__snake_case      :							Optional[Any]						=			'<unk> UNwanted , running'
					__snake_case      :							Optional[Any]						=			'<unk> unwanted, running'
					return input_text, output_text



				def  _lowercase					(self    :				Optional[int])   ->     str:
					__snake_case      :							Dict						=			TransfoXLTokenizer(vocab_file=self.vocab_file     ,  lower_case=__lowercase)

					__snake_case      :							List[str]						=			tokenizer.tokenize('<unk> UNwanted , running')
					self.assertListEqual(__lowercase     ,  ['<unk>', 'unwanted', ',', 'running'])

					self.assertListEqual(tokenizer.convert_tokens_to_ids(__lowercase)     ,  [0, 4, 8, 7])



				def  _lowercase					(self    :				Union[str, Any])   ->     Optional[Any]:
					__snake_case      :							Optional[Any]						=			TransfoXLTokenizer(lower_case=__lowercase)

					self.assertListEqual(
					    tokenizer.tokenize(' \tHeLLo ! how  \n Are yoU ?  ')     ,  ['hello', '!', 'how', 'are', 'you', '?'])



				def  _lowercase					(self    :				Tuple)   ->     Optional[int]:
					__snake_case      :							Optional[int]						=			TransfoXLTokenizer(lower_case=__lowercase)

					self.assertListEqual(
					    tokenizer.tokenize(' \tHeLLo ! how  \n Are yoU ?  ')     ,  ['HeLLo', '!', 'how', 'Are', 'yoU', '?'])



				def  _lowercase					(self    :				List[str])   ->     Any:
					__snake_case      :							Optional[Any]						=			TransfoXLTokenizer(lower_case=__lowercase)
					__snake_case      :							List[str]						=			'Hello (bracket) and side-scrolled [and] Henry\'s $5,000 with 3.34 m. What\'s up!?'
					__snake_case      :							int						=			[
					    'Hello',
					    '(',
					    'bracket',
					    ')',
					    'and',
					    'side',
					    '@-@',
					    'scrolled',
					    '[',
					    'and',
					    ']',
					    'Henry',
					    '\'s',
					    '$',
					    '5',
					    '@,@',
					    '000',
					    'with',
					    '3',
					    '@.@',
					    '34',
					    'm',
					    '.',
					    'What',
					    '\'s',
					    'up',
					    '!',
					    '?',
					]

					self.assertListEqual(tokenizer.tokenize(__lowercase)     ,  __lowercase)

					self.assertEqual(tokenizer.convert_tokens_to_string(__lowercase)     ,  __lowercase)






				def  _lowercase					(self    :				Optional[Any])   ->     List[Any]:
					__snake_case      :							Optional[Any]						=			self.get_tokenizer()
					__snake_case      :							Dict						=			len(__lowercase)

					tokenizer.add_tokens(['new1', 'new2'])
					tokenizer.move_added_token('new1'     ,  1)

					# Check that moved token is not copied (duplicate)
					self.assertEqual(len(__lowercase)     ,  original_len + 2)
					# Check that token is moved to specified id
					self.assertEqual(tokenizer.encode('new1')     ,  [1])
					self.assertEqual(tokenizer.decode([1])     ,  'new1')






"""simple docstring"""







def   __UpperCAmelCase    (   UpperCAmelCase_   :    int      ,							UpperCAmelCase_   :    int  )							->      int:

	'''simple docstring'''





	while a != 0:
		__snake_case		,    __snake_case      :							Union[str, Any]						=			b % a, a
	return b

def   __UpperCAmelCase    (   UpperCAmelCase_   :    int      ,							UpperCAmelCase_   :    int  )							->      int:

	'''simple docstring'''





	if gcd(UpperCAmelCase_      ,							UpperCAmelCase_  ) != 1:
		__snake_case      :							Union[str, Any]						=			F"mod inverse of {a!r} and {m!r} does not exist"
		raise ValueError(UpperCAmelCase_  )
	__snake_case		,    __snake_case		,    __snake_case      :							List[str]						=			1, 0, a
	__snake_case		,    __snake_case		,    __snake_case      :							Dict						=			0, 1, m
	while va != 0:
		__snake_case      :							List[str]						=			ua // va
		__snake_case		,    __snake_case		,    __snake_case		,    __snake_case		,    __snake_case		,    __snake_case      :							List[str]						=			(ua - q * va), (ua - q * va), (ua - q * va), va, va, va
	return ua % m





