






"""simple docstring"""



import json
import os
import unittest

from transformers import HerbertTokenizer, HerbertTokenizerFast
from transformers.models.herbert.tokenization_herbert import VOCAB_FILES_NAMES
from transformers.testing_utils import get_tests_dir, require_tokenizers, slow

from ...test_tokenization_common import TokenizerTesterMixin




@require_tokenizers
class        __lowercase(       _UpperCamelCase						,							unittest.TestCase  ):
						lowerCAmelCase_		:							Dict=       HerbertTokenizer
						lowerCAmelCase_		:							str=       HerbertTokenizerFast
						lowerCAmelCase_		:							Any=       True






						def 		lowerCAmelCase   (					self)			->  str:




											"""simple docstring"""





											super().setUp()

											# Use a simpler test file without japanese/chinese characters
											with open(F"{get_tests_dir()}/fixtures/sample_text_no_unicode.txt"    ,						encoding='utf-8') as f_data:
																lowerCamelCase__				=f_data.read().replace('\n\n'    ,						'\n').strip()

											lowerCamelCase__				=[
											    '<s>',
											    '</s>',
											    '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>',
											    ',</w>',
											    '<unk>',
											]
											lowerCamelCase__				=dict(zip(_SCREAMING_SNAKE_CASE    ,						range(len(_SCREAMING_SNAKE_CASE))))
											lowerCamelCase__				=['l o 123', 'lo w 1456', 'e r</w> 1789', '']

											lowerCamelCase__				=os.path.join(self.tmpdirname    ,						VOCAB_FILES_NAMES['vocab_file'])
											lowerCamelCase__				=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 		lowerCAmelCase   (					self    ,						_SCREAMING_SNAKE_CASE)			->  str:




											"""simple docstring"""





											lowerCamelCase__				='lower newer'
											lowerCamelCase__				='lower newer'
											return input_text, output_text






						def 		lowerCAmelCase   (					self)			->  str:




											"""simple docstring"""





											lowerCamelCase__				=self.tokenizer_class(vocab_file=self.vocab_file    ,						merges_file=self.merges_file)

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

											lowerCamelCase__				=tokens + ['<unk>']
											lowerCamelCase__				=[16, 17, 23]
											self.assertListEqual(tokenizer.convert_tokens_to_ids(_SCREAMING_SNAKE_CASE)    ,						_SCREAMING_SNAKE_CASE)






						def 		lowerCAmelCase   (					self)			->  Any:




											"""simple docstring"""





											if not self.test_rust_tokenizer:
																return

											lowerCamelCase__				=self.get_tokenizer()
											lowerCamelCase__				=self.get_rust_tokenizer()

											lowerCamelCase__				='lower,newer'

											lowerCamelCase__				=tokenizer.tokenize(_SCREAMING_SNAKE_CASE)
											lowerCamelCase__				=rust_tokenizer.tokenize(_SCREAMING_SNAKE_CASE)
											self.assertListEqual(_SCREAMING_SNAKE_CASE    ,						_SCREAMING_SNAKE_CASE)

											lowerCamelCase__				=tokenizer.encode(_SCREAMING_SNAKE_CASE    ,						add_special_tokens=_SCREAMING_SNAKE_CASE)
											lowerCamelCase__				=rust_tokenizer.encode(_SCREAMING_SNAKE_CASE    ,						add_special_tokens=_SCREAMING_SNAKE_CASE)
											self.assertListEqual(_SCREAMING_SNAKE_CASE    ,						_SCREAMING_SNAKE_CASE)

											lowerCamelCase__				=self.get_rust_tokenizer()
											lowerCamelCase__				=tokenizer.encode(_SCREAMING_SNAKE_CASE)
											lowerCamelCase__				=rust_tokenizer.encode(_SCREAMING_SNAKE_CASE)
											self.assertListEqual(_SCREAMING_SNAKE_CASE    ,						_SCREAMING_SNAKE_CASE)






						@slow
						def 		lowerCAmelCase   (					self)			->  List[Any]:




											"""simple docstring"""





											lowerCamelCase__				=self.tokenizer_class.from_pretrained('allegro/herbert-base-cased')

											lowerCamelCase__				=tokenizer.encode('konstruowanie sekwencji'    ,						add_special_tokens=_SCREAMING_SNAKE_CASE)
											lowerCamelCase__				=tokenizer.encode('konstruowanie wielu sekwencji'    ,						add_special_tokens=_SCREAMING_SNAKE_CASE)

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

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







"""simple docstring"""



from doctest import testmod
from math import sqrt




def 						lowerCamelCase_				(  __A  :		int			):
					lowerCamelCase__				=[]
					if num < 1:
										return facs
					facs.append(1			)
					if num == 1:
										return facs
					facs.append(__A			)
					for i in range(2			,	int(sqrt(__A			)			) + 1			):
										if num % i == 0:  # If i is a factor of num
															facs.append(__A			)
															lowerCamelCase__				=num // i  # num//i is the other factor of num
															if d != i:  # If d and i are distinct
																				facs.append(__A			)  # we have found another factor
					facs.sort()
					return facs


if __name__ == "__main__":
						testmod(name="factors_of_a_number", verbose=True)