




'''simple docstring'''



import json
import os
import unittest

from transformers.models.gptsan_japanese.tokenization_gptsan_japanese import (
    VOCAB_FILES_NAMES,
    GPTSanJapaneseTokenizer,
)
from transformers.testing_utils import require_tokenizers, slow

from ...test_tokenization_common import TokenizerTesterMixin






@require_tokenizers
class 							_a				(			SCREAMING_SNAKE_CASE ,      unittest.TestCase ):





       '''simple docstring'''






       A						:				List[str]        =						GPTSanJapaneseTokenizer
       A						:				Optional[Any]        =						False
       A						:				List[Any]        =						{'''do_clean_text''': False, '''add_prefix_space''': False}







       def        UpperCamelCase_							(      self  ):







             '''simple docstring'''







             super().setUp()

             # fmt: off
             SCREAMING_SNAKE_CASE   :      Union[str, Any]    					=						['こん', 'こんに', 'にちは', 'ばんは', '世界,㔺界', '、', '。', '<BR>', '<SP>', '<TAB>', '<URL>', '<EMAIL>', '<TEL>', '<DATE>', '<PRICE>', '<BLOCK>', '<KIGOU>', '<U2000U2BFF>', '<|emoji1|>', '<unk>', '<|bagoftoken|>', '<|endoftext|>']
             # fmt: on
             SCREAMING_SNAKE_CASE   :      Optional[Any]    					=						{'emoji': {'\ud83d\ude00': '<|emoji1|>'}, 'emoji_inv': {'<|emoji1|>': '\ud83d\ude00'}}  # 😀
             SCREAMING_SNAKE_CASE   :      Tuple    					=						{'unk_token': '<unk>'}

             SCREAMING_SNAKE_CASE   :      Any    					=						os.path.join(self.tmpdirname,							VOCAB_FILES_NAMES['vocab_file']  )
             SCREAMING_SNAKE_CASE   :      List[str]    					=						os.path.join(self.tmpdirname,							VOCAB_FILES_NAMES['emoji_file']  )
             with open(self.vocab_file,							'w',							encoding='utf-8'  ) as vocab_writer:
                   vocab_writer.write(''.join([x + '\n' for x in vocab_tokens]  )  )
             with open(self.emoji_file,							'w'  ) as emoji_writer:
                   emoji_writer.write(json.dumps(A  )  )







       def        UpperCamelCase_							(      self,							**A  ):







             '''simple docstring'''







             kwargs.update(self.special_tokens_map  )
             return GPTSanJapaneseTokenizer.from_pretrained(self.tmpdirname,							**A  )







       def        UpperCamelCase_							(      self,							A  ):







             '''simple docstring'''







             SCREAMING_SNAKE_CASE   :      List[Any]    					=						'こんにちは、世界。 \nこんばんは、㔺界。😀'
             SCREAMING_SNAKE_CASE   :      Union[str, Any]    					=						'こんにちは、世界。 \nこんばんは、世界。😀'
             return input_text, output_text







       def        UpperCamelCase_							(      self,							A  ):







             '''simple docstring'''







             SCREAMING_SNAKE_CASE					,    SCREAMING_SNAKE_CASE   :      str    					=						self.get_input_output_texts(A  )
             SCREAMING_SNAKE_CASE   :      str    					=						tokenizer.encode(A,							add_special_tokens=A  )
             SCREAMING_SNAKE_CASE   :      Tuple    					=						tokenizer.decode(A,							clean_up_tokenization_spaces=A  )
             return text, ids







       def        UpperCamelCase_							(      self  ):







             '''simple docstring'''







             pass  # TODO add if relevant







       def        UpperCamelCase_							(      self  ):







             '''simple docstring'''







             pass  # TODO add if relevant







       def        UpperCamelCase_							(      self  ):







             '''simple docstring'''







             pass  # TODO add if relevant







       def        UpperCamelCase_							(      self  ):







             '''simple docstring'''







             SCREAMING_SNAKE_CASE   :      Union[str, Any]    					=						self.get_tokenizer()

             # Testing tokenization
             SCREAMING_SNAKE_CASE   :      int    					=						'こんにちは、世界。　こんばんは、㔺界。'
             SCREAMING_SNAKE_CASE   :      str    					=						['こん', 'にちは', '、', '世界', '。', '<SP>', 'こん', 'ばんは', '、', '㔺界', '。']
             SCREAMING_SNAKE_CASE   :      Optional[Any]    					=						tokenizer.tokenize(A  )
             self.assertListEqual(A,							A  )

             # Testing conversion to ids without special tokens
             SCREAMING_SNAKE_CASE   :      Union[str, Any]    					=						[0, 2, 5, 4, 6, 8, 0, 3, 5, 4, 6]
             SCREAMING_SNAKE_CASE   :      List[Any]    					=						tokenizer.convert_tokens_to_ids(A  )
             self.assertListEqual(A,							A  )

             # Testing conversion to ids with special tokens
             SCREAMING_SNAKE_CASE   :      Union[str, Any]    					=						tokens + [tokenizer.unk_token]
             SCREAMING_SNAKE_CASE   :      Optional[int]    					=						[0, 2, 5, 4, 6, 8, 0, 3, 5, 4, 6, 19]
             SCREAMING_SNAKE_CASE   :      List[Any]    					=						tokenizer.convert_tokens_to_ids(A  )
             self.assertListEqual(A,							A  )







       def        UpperCamelCase_							(      self  ):







             '''simple docstring'''







             SCREAMING_SNAKE_CASE   :      int    					=						self.get_tokenizer()

             # Testing tokenization
             SCREAMING_SNAKE_CASE   :      int    					=						'こんにちは、<|bagoftoken|>世界。こんばんは、<|bagoftoken|>㔺界。'
             SCREAMING_SNAKE_CASE   :      List[str]    					=						'こんにちは、、、、世界。こんばんは、、、、世界。'
             SCREAMING_SNAKE_CASE   :      str    					=						tokenizer.encode(A  )
             SCREAMING_SNAKE_CASE   :      str    					=						tokenizer.decode(A  )
             self.assertEqual(A,							A  )







       @slow
       def        UpperCamelCase_							(      self  ):







             '''simple docstring'''







             SCREAMING_SNAKE_CASE   :      List[str]    					=						self.tokenizer_class.from_pretrained('Tanrei/GPTSAN-japanese'  )

             # Testing tokenization
             SCREAMING_SNAKE_CASE   :      List[Any]    					=						'こんにちは、世界。'
             SCREAMING_SNAKE_CASE   :      Dict    					=						'こんばんは、㔺界。😀'
             SCREAMING_SNAKE_CASE   :      List[Any]    					=						'こんにちは、世界。こんばんは、世界。😀'
             SCREAMING_SNAKE_CASE   :      Tuple    					=						tokenizer.encode(prefix_text + input_text  )
             SCREAMING_SNAKE_CASE   :      Optional[Any]    					=						tokenizer.encode('',							prefix_text=prefix_text + input_text  )
             SCREAMING_SNAKE_CASE   :      int    					=						tokenizer.encode(A,							prefix_text=A  )
             SCREAMING_SNAKE_CASE   :      List[str]    					=						tokenizer.decode(A  )
             SCREAMING_SNAKE_CASE   :      Any    					=						tokenizer.decode(A  )
             SCREAMING_SNAKE_CASE   :      Any    					=						tokenizer.decode(A  )
             self.assertEqual(A,							A  )
             self.assertEqual(A,							A  )
             self.assertEqual(A,							A  )







       @slow
       def        UpperCamelCase_							(      self  ):







             '''simple docstring'''







             SCREAMING_SNAKE_CASE   :      Optional[int]    					=						self.tokenizer_class.from_pretrained('Tanrei/GPTSAN-japanese'  )

             # Testing tokenization
             SCREAMING_SNAKE_CASE   :      Optional[Any]    					=						'こんにちは、世界。'
             SCREAMING_SNAKE_CASE   :      Dict    					=						'こんばんは、㔺界。😀'

             SCREAMING_SNAKE_CASE   :      str    					=						len(tokenizer.encode(A  )  ) - 2
             SCREAMING_SNAKE_CASE   :      Optional[Any]    					=						len(tokenizer.encode(A  )  ) - 2

             SCREAMING_SNAKE_CASE   :      Union[str, Any]    					=						[1] + [0] * (len_prefix + len_text + 1)
             SCREAMING_SNAKE_CASE   :      Optional[Any]    					=						[1] * (len_prefix + len_text + 1) + [0]
             SCREAMING_SNAKE_CASE   :      List[str]    					=						[1] + [1] * (len_prefix) + [0] * (len_text + 1)

             SCREAMING_SNAKE_CASE   :      List[Any]    					=						tokenizer(prefix_text + input_text  ).token_type_ids
             SCREAMING_SNAKE_CASE   :      Tuple    					=						tokenizer('',							prefix_text=prefix_text + input_text  ).token_type_ids
             SCREAMING_SNAKE_CASE   :      List[str]    					=						tokenizer(A,							prefix_text=A  ).token_type_ids
             self.assertListEqual(A,							A  )
             self.assertListEqual(A,							A  )
             self.assertListEqual(A,							A  )







       @slow
       def        UpperCamelCase_							(      self  ):







             '''simple docstring'''







             SCREAMING_SNAKE_CASE   :      List[str]    					=						self.tokenizer_class.from_pretrained('Tanrei/GPTSAN-japanese'  )

             SCREAMING_SNAKE_CASE   :      str    					=						tokenizer.encode('あンいワ'  )
             SCREAMING_SNAKE_CASE   :      Optional[Any]    					=						tokenizer.encode('',							prefix_text='あンいワ'  )
             SCREAMING_SNAKE_CASE   :      Optional[int]    					=						tokenizer.encode('いワ',							prefix_text='あン'  )

             self.assertEqual(tokenizer.decode(A  ),							tokenizer.decode(A  )  )
             self.assertEqual(tokenizer.decode(A  ),							tokenizer.decode(A  )  )
             self.assertNotEqual(A,							A  )
             self.assertNotEqual(A,							A  )
             self.assertEqual(x_token_a[1],							x_token_a[-1]  )  # SEG token
             self.assertEqual(x_token_a[1],							x_token_a[3]  )  # SEG token







       @slow
       def        UpperCamelCase_							(      self  ):







             '''simple docstring'''







             SCREAMING_SNAKE_CASE   :      Optional[Any]    					=						self.tokenizer_class.from_pretrained('Tanrei/GPTSAN-japanese'  )

             SCREAMING_SNAKE_CASE   :      Any    					=						[['武田信玄', 'は、'], ['織田信長', 'の配下の、']]
             SCREAMING_SNAKE_CASE   :      Any    					=						tokenizer(A,							padding=A  )
             SCREAMING_SNAKE_CASE   :      Optional[int]    					=						tokenizer.batch_encode_plus(A,							padding=A  )

             # fmt: off
             SCREAMING_SNAKE_CASE   :      int    					=						[[35_993, 8_640, 25_948, 35_998, 30_647, 35_675, 35_999, 35_999], [35_993, 10_382, 9_868, 35_998, 30_646, 9_459, 30_646, 35_675]]
             SCREAMING_SNAKE_CASE   :      str    					=						[[1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0]]
             SCREAMING_SNAKE_CASE   :      List[Any]    					=						[[1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1]]
             # fmt: on
             self.assertListEqual(x_token.input_ids,							A  )
             self.assertListEqual(x_token.token_type_ids,							A  )
             self.assertListEqual(x_token.attention_mask,							A  )
             self.assertListEqual(x_token_a.input_ids,							A  )
             self.assertListEqual(x_token_a.token_type_ids,							A  )
             self.assertListEqual(x_token_a.attention_mask,							A  )







       def        UpperCamelCase_							(      self  ):







             '''simple docstring'''







             pass







       def        UpperCamelCase_							(      self  ):







             '''simple docstring'''







             pass






'''simple docstring'''





import math






def 						UpperCAmelCase__(				_SCREAMING_SNAKE_CASE					: int ):






			"""simple docstring"""




			if not isinstance(_SCREAMING_SNAKE_CASE,_SCREAMING_SNAKE_CASE ):
						__A=	f"""Input value of [number={number}] must be an integer"""
						raise TypeError(_SCREAMING_SNAKE_CASE )

			if number < 1:
						__A=	f"""Input value of [number={number}] must be > 0"""
						raise ValueError(_SCREAMING_SNAKE_CASE )
			elif number == 1:
						return 3
			elif number == 2:
						return 5
			else:
						__A=	int(math.log(number // 3,2 ) ) + 2

						__A=	[3, 5]
						__A=	2
						__A=	3
						for block in range(1,_SCREAMING_SNAKE_CASE ):
									for _ in range(_SCREAMING_SNAKE_CASE ):
												proth_list.append(2 ** (block + 1) + proth_list[proth_index - 1] )
												proth_index += 1
									increment *= 2

			return proth_list[number - 1]


if __name__ == "__main__":
					import doctest

					doctest.testmod()

					for number in range(1_1):
										UpperCAmelCase__  			=				0
										try:
															UpperCAmelCase__  			=				proth(number)
										except ValueError:
															print(F"""ValueError: there is no {number}th Proth number""")
															continue

										print(F"""The {number}th Proth number: {value}""")



