import collections
import json
import os
import re
from typing import TYPE_CHECKING, List, Optional, Tuple

import numpy as np

from ...tokenization_utils_fast import PreTrainedTokenizer
from ...utils import logging


if TYPE_CHECKING:
							from transformers.pipelines.conversational import Conversation


_lowerCamelCase					:   Optional[Any]							=		logging.get_logger(__name__)

_lowerCamelCase					:   Dict							=		{'''vocab_file''': '''vocab.txt''', '''emoji_file''': '''emoji.json'''}

_lowerCamelCase					:   Any							=		{
    '''vocab_file''': {
        '''abeja/gpt-neox-japanese-2.7b''': '''https://huggingface.co/abeja/gpt-neox-japanese-2.7b/resolve/main/vocab.txt''',
    },
    '''emoji_file''': {
        '''abeja/gpt-neox-japanese-2.7b''': '''https://huggingface.co/abeja/gpt-neox-japanese-2.7b/resolve/main/emoji.json''',
    },
}

_lowerCamelCase					:   Optional[Any]							=		{
    '''abeja/gpt-neox-japanese-2.7b''': 20_48,
}





def 	__lowerCamelCase							(UpperCAmelCase__     :							Tuple      , UpperCAmelCase__     :							Optional[Any]  ):
					with open(UpperCAmelCase__      , "r"      , encoding="utf-8"  ) as f:
										SCREAMING_SNAKE_CASE    			=       json.loads(f.read()  )

					SCREAMING_SNAKE_CASE    			=       collections.OrderedDict()
					SCREAMING_SNAKE_CASE    			=       collections.OrderedDict()
					SCREAMING_SNAKE_CASE    			=       collections.OrderedDict()
					with open(UpperCAmelCase__      , "r"      , encoding="utf-8"  ) as f:
										SCREAMING_SNAKE_CASE    			=       f.readlines()
					SCREAMING_SNAKE_CASE    			=       [[t.rstrip("\n"  )] if (t == "," or "," not in t) else t.rstrip("\n"  ).split(","  ) for t in token]
					for idx, b in enumerate(UpperCAmelCase__  ):
										SCREAMING_SNAKE_CASE    			=       b
										SCREAMING_SNAKE_CASE    			=       idx
										for wd in b:
															SCREAMING_SNAKE_CASE    			=       idx

					return vocab, raw_vocab, ids_to_tokens, emoji


class 						lowercase    (     a     ):
							lowercase__						:       List[Any]								=							VOCAB_FILES_NAMES
							lowercase__						:       Optional[int]								=							PRETRAINED_VOCAB_FILES_MAP
							lowercase__						:       Optional[int]								=							PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
							lowercase__						:       Optional[int]								=							["""input_ids""", """attention_mask"""]




							def __init__(						self   :					Dict	,							_UpperCamelCase   :					Optional[Any]	,							_UpperCamelCase   :					Optional[Any]	,							_UpperCamelCase   :					Dict="<|endoftext|>"	,							_UpperCamelCase   :					Tuple="<|endoftext|>"	,							_UpperCamelCase   :					int="<|startoftext|>"	,							_UpperCamelCase   :					int="<|endoftext|>"	,							_UpperCamelCase   :					Optional[Any]=False	,							**_UpperCamelCase   :					Tuple	,							)					->				Tuple:



												'''simple docstring'''

												super().__init__(
												    unk_token=_UpperCamelCase	,							pad_token=_UpperCamelCase	,							bos_token=_UpperCamelCase	,							eos_token=_UpperCamelCase	,							do_clean_text=_UpperCamelCase	,							**_UpperCamelCase	,							)
												if not os.path.isfile(_UpperCamelCase      ):
																	raise ValueError(
																	    F"Can't find a vocabulary file at path '{vocab_file}'. To load the vocabulary from a Google pretrained"
																	    " model use `tokenizer = GPTNeoXJapaneseokenizer.from_pretrained(PRETRAINED_MODEL_NAME)`"      )
												if not os.path.isfile(_UpperCamelCase      ):
																	raise ValueError(
																	    F"Can't find a emoji file at path '{emoji_file}'. To load the emoji information from a Google"
																	    " pretrained model use `tokenizer = GPTNeoXJapaneseokenizer.from_pretrained(PRETRAINED_MODEL_NAME)`"      )
												SCREAMING_SNAKE_CASE    			=       do_clean_text
												SCREAMING_SNAKE_CASE			,   SCREAMING_SNAKE_CASE			,   SCREAMING_SNAKE_CASE			,   SCREAMING_SNAKE_CASE    			=       load_vocab_and_emoji(_UpperCamelCase	,							_UpperCamelCase      )
												SCREAMING_SNAKE_CASE    			=       SubWordJapaneseTokenizer(
												    vocab=self.vocab	,							ids_to_tokens=self.ids_to_tokens	,							emoji=self.emoji      )




							@property
							def 	__snake_case(						self   :					int      )					->				int:



												'''simple docstring'''

												return len(self.raw_vocab      )




							def 	__snake_case(						self   :					Optional[Any]      )					->				str:



												'''simple docstring'''

												return dict(self.raw_vocab	,							**self.added_tokens_encoder      )




							def 	__snake_case(						self   :					Dict	,							_UpperCamelCase   :					int      )					->				Optional[Any]:



												'''simple docstring'''

												return self.subword_tokenizer.tokenize(_UpperCamelCase	,							clean=self.do_clean_text      )




							def 	__snake_case(						self   :					Union[str, Any]	,							_UpperCamelCase   :					str      )					->				Any:



												'''simple docstring'''

												return self.vocab.get(_UpperCamelCase	,							self.vocab.get(self.unk_token      )      )




							def 	__snake_case(						self   :					Optional[Any]	,							_UpperCamelCase   :					Optional[int]      )					->				Dict:



												'''simple docstring'''

												return self.subword_tokenizer.convert_id_to_token(_UpperCamelCase      )




							def 	__snake_case(						self   :					Optional[Any]	,							_UpperCamelCase   :					str      )					->				List[Any]:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       "".join(_UpperCamelCase      ).strip()
												return out_string




							def 	__snake_case(						self   :					Tuple	,							_UpperCamelCase   :					"Conversation"      )					->				List[int]:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       []
												for is_user, text in conversation.iter_texts():
																	input_ids.extend(self.encode(_UpperCamelCase	,							add_special_tokens=_UpperCamelCase      ) + [self.eos_token_id]      )

												if len(_UpperCamelCase      ) > self.model_max_length:
																	SCREAMING_SNAKE_CASE    			=       input_ids[-self.model_max_length :]
												return input_ids





							def 	__snake_case(						self   :					Tuple	,							_UpperCamelCase   :					str	,							_UpperCamelCase   :					Optional[str] = None      )					->				Tuple[str]:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       0
												if os.path.isdir(_UpperCamelCase      ):
																	SCREAMING_SNAKE_CASE    			=       os.path.join(
																	    _UpperCamelCase	,							(filename_prefix + "-" if filename_prefix else "") + VOCAB_FILES_NAMES["vocab_file"]      )
																	SCREAMING_SNAKE_CASE    			=       os.path.join(
																	    _UpperCamelCase	,							(filename_prefix + "-" if filename_prefix else "") + VOCAB_FILES_NAMES["emoji_file"]      )
												else:
																	SCREAMING_SNAKE_CASE    			=       (
																	    (filename_prefix + "-" if filename_prefix else "") + save_directory + VOCAB_FILES_NAMES["vocab_file"]
																	)
																	SCREAMING_SNAKE_CASE    			=       (
																	    (filename_prefix + "-" if filename_prefix else "") + save_directory + VOCAB_FILES_NAMES["emoji_file"]
																	)
												with open(_UpperCamelCase	,							"w"	,							encoding="utf-8"      ) as writer:
																	for token_index, token in self.ids_to_tokens.items():
																						if index != token_index:
																											logger.warning(
																											    F"Saving vocabulary to {vocab_file}: vocabulary indices are not consecutive."
																											    " Please check that the vocabulary is not corrupted!"      )
																											SCREAMING_SNAKE_CASE    			=       token_index
																						writer.write(",".join(_UpperCamelCase      ) + "\n"      )
																						index += 1
												with open(_UpperCamelCase	,							"w"	,							encoding="utf-8"      ) as writer:
																	json.dump(self.emoji	,							_UpperCamelCase      )
												return vocab_file, emoji_file



class 						lowercase    (     a     ):




							def __init__(						self   :					Dict	,							_UpperCamelCase   :					Tuple	,							_UpperCamelCase   :					Optional[int]	,							_UpperCamelCase   :					Tuple      )					->				List[Any]:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       vocab  # same as swe
												SCREAMING_SNAKE_CASE    			=       ids_to_tokens  # same as bpe
												SCREAMING_SNAKE_CASE    			=       emoji
												SCREAMING_SNAKE_CASE    			=       np.max([len(_UpperCamelCase      ) for w in self.vocab.keys()]      )
												SCREAMING_SNAKE_CASE    			=       re.compile(R"(https?|ftp)(:\/\/[-_\.!~*\'()a-zA-Z0-9;\/?:\@&=\+$,%#]+)"      )
												SCREAMING_SNAKE_CASE    			=       re.compile(R"[A-Za-z0-9\._+]*@[\-_0-9A-Za-z]+(\.[A-Za-z]+)*"      )
												SCREAMING_SNAKE_CASE    			=       re.compile(R"[\(]{0,1}[0-9]{2,4}[\)\-\(]{0,1}[0-9]{2,4}[\)\-]{0,1}[0-9]{3,4}"      )
												SCREAMING_SNAKE_CASE    			=       re.compile(
												    R"([12]\d{3}[/\-年])*(0?[1-9]|1[0-2])[/\-月]((0?[1-9]|[12][0-9]|3[01])日?)*(\d{1,2}|:|\d{1,2}時|\d{1,2}分|\(日\)|\(月\)|\(火\)|\(水\)|\(木\)|\(金\)|\(土\)|㈰|㈪|㈫|㈬|㈭|㈮|㈯)*"      )
												SCREAMING_SNAKE_CASE    			=       re.compile(
												    R"(明治|大正|昭和|平成|令和|㍾|㍽|㍼|㍻|\u32ff)\d{1,2}年(0?[1-9]|1[0-2])月(0?[1-9]|[12][0-9]|3[01])日(\d{1,2}|:|\d{1,2}時|\d{1,2}分|\(日\)|\(月\)|\(火\)|\(水\)|\(木\)|\(金\)|\(土\)|㈰|㈪|㈫|㈬|㈭|㈮|㈯)*"      )
												SCREAMING_SNAKE_CASE    			=       re.compile(
												    R"((0|[1-9]\d*|[1-9]\d{0,2}(,\d{3})+)*億)*((0|[1-9]\d*|[1-9]\d{0,2}(,\d{3})+)*万)*((0|[1-9]\d*|[1-9]\d{0,2}(,\d{3})+)*千)*(0|[1-9]\d*|[1-9]\d{0,2}(,\d{3})+)*(千円|万円|千万円|円|千ドル|万ドル|千万ドル|ドル|千ユーロ|万ユーロ|千万ユーロ|ユーロ)+(\(税込\)|\(税抜\)|\+tax)*"      )
												SCREAMING_SNAKE_CASE    			=       "─━│┃┄┅┆┇┈┉┊┋┌┍┎┏┐┑┒┓└┕┖┗┘┙┚┛├┝┞┟┠┡┢┣┤┥┦┧┨┩┪┫┬┭┮┯┰┱┲┳┴┵┶┷┸┹┺┻┼┽┾┿╀╁╂╃╄╅╆╇╈╉╊╋╌╍╎╏═║╒╓╔╕╖╗╘╙╚╛╜╝╞╟╠╡╢╣╤╥╦╧╨╩╪╫╬╭╮╯╰╱╲╳╴╵╶╷╸╹╺╻╼╽╾╿"
												SCREAMING_SNAKE_CASE    			=       "▀▁▂▃▄▅▆▇█▉▊▋▌▍▎▏▐░▒▓▔▕▖▗▘▙▚▛▜▝▞▟"
												SCREAMING_SNAKE_CASE    			=       str.maketrans({k: "<BLOCK>" for k in keisen + blocks}      )




							def __len__(						self   :					Tuple      )					->				List[Any]:



												'''simple docstring'''

												return len(self.ids_to_tokens      )




							def 	__snake_case(						self   :					Optional[int]	,							_UpperCamelCase   :					Union[str, Any]      )					->				Optional[int]:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       self.content_repattera.sub("<URL>"	,							_UpperCamelCase      )
												SCREAMING_SNAKE_CASE    			=       self.content_repattera.sub("<EMAIL>"	,							_UpperCamelCase      )
												SCREAMING_SNAKE_CASE    			=       self.content_repattera.sub("<TEL>"	,							_UpperCamelCase      )
												SCREAMING_SNAKE_CASE    			=       self.content_repattera.sub("<DATE>"	,							_UpperCamelCase      )
												SCREAMING_SNAKE_CASE    			=       self.content_repattera.sub("<DATE>"	,							_UpperCamelCase      )
												SCREAMING_SNAKE_CASE    			=       self.content_repattera.sub("<PRICE>"	,							_UpperCamelCase      )
												SCREAMING_SNAKE_CASE    			=       content.translate(self.content_transa      )
												while "<BLOCK><BLOCK>" in content:
																	SCREAMING_SNAKE_CASE    			=       content.replace("<BLOCK><BLOCK>"	,							"<BLOCK>"      )
												return content




							def 	__snake_case(						self   :					List[Any]	,							_UpperCamelCase   :					Optional[int]	,							_UpperCamelCase   :					Union[str, Any]=False      )					->				Union[str, Any]:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       text.replace(" "	,							"<SP>"      )
												SCREAMING_SNAKE_CASE    			=       text.replace("　"	,							"<SP>"      )
												SCREAMING_SNAKE_CASE    			=       text.replace("\r\n"	,							"<BR>"      )
												SCREAMING_SNAKE_CASE    			=       text.replace("\n"	,							"<BR>"      )
												SCREAMING_SNAKE_CASE    			=       text.replace("\r"	,							"<BR>"      )
												SCREAMING_SNAKE_CASE    			=       text.replace("\t"	,							"<TAB>"      )
												SCREAMING_SNAKE_CASE    			=       text.replace("—"	,							"ー"      )
												SCREAMING_SNAKE_CASE    			=       text.replace("−"	,							"ー"      )
												for k, v in self.emoji["emoji"].items():
																	if k in text:
																						SCREAMING_SNAKE_CASE    			=       text.replace(_UpperCamelCase	,							_UpperCamelCase      )
												if clean:
																	SCREAMING_SNAKE_CASE    			=       self.clean_text(_UpperCamelCase      )

												def check_simbol(_UpperCamelCase   :					Union[str, Any]      ):
																	SCREAMING_SNAKE_CASE    			=       x.encode()
																	if len(_UpperCamelCase      ) == 1 and len(_UpperCamelCase      ) == 2:
																						SCREAMING_SNAKE_CASE    			=       (int(e[0]      ) << 8) + int(e[1]      )
																						if (
																						    (c >= 0xC_2_A_1 and c <= 0xC_2_B_F)
																						    or (c >= 0xC_7_8_0 and c <= 0xC_7_8_3)
																						    or (c >= 0xC_A_B_9 and c <= 0xC_B_B_F)
																						    or (c >= 0xC_C_8_0 and c <= 0xC_D_A_2)
																						):
																											return True
																	return False

												def checkuae(_UpperCamelCase   :					Optional[Any]      ):
																	SCREAMING_SNAKE_CASE    			=       x.encode()
																	if len(_UpperCamelCase      ) == 1 and len(_UpperCamelCase      ) == 3:
																						SCREAMING_SNAKE_CASE    			=       (int(e[0]      ) << 16) + (int(e[1]      ) << 8) + int(e[2]      )
																						if c >= 0xE_2_8_0_8_0 and c <= 0xE_2_B_0_7_F:
																											return True
																	return False

												SCREAMING_SNAKE_CASE    			=       0
												SCREAMING_SNAKE_CASE    			=       []
												while pos < len(_UpperCamelCase      ):
																	SCREAMING_SNAKE_CASE    			=       min(len(_UpperCamelCase      )	,							pos + self.maxlen + 1      ) if text[pos] == "<" else pos + 3
																	SCREAMING_SNAKE_CASE    			=       []  # (token_id, token, pos)
																	for e in range(_UpperCamelCase	,							_UpperCamelCase	,							-1      ):
																						SCREAMING_SNAKE_CASE    			=       text[pos:e]
																						if wd in self.vocab:
																											if wd[0] == "<" and len(_UpperCamelCase      ) > 2:
																																SCREAMING_SNAKE_CASE    			=       [(self.vocab[wd], wd, e)]
																																break
																											else:
																																candidates.append((self.vocab[wd], wd, e)      )
																	if len(_UpperCamelCase      ) > 0:
																						# the smallest token_id is adopted
																						SCREAMING_SNAKE_CASE			,   SCREAMING_SNAKE_CASE			,   SCREAMING_SNAKE_CASE    			=       sorted(_UpperCamelCase	,							key=lambda _UpperCamelCase      : x[0]      )[0]
																						result.append(_UpperCamelCase      )
																						SCREAMING_SNAKE_CASE    			=       e
																	else:
																						SCREAMING_SNAKE_CASE    			=       pos + 1
																						SCREAMING_SNAKE_CASE    			=       text[pos:end]
																						if check_simbol(_UpperCamelCase      ):
																											result.append("<KIGOU>"      )
																						elif checkuae(_UpperCamelCase      ):
																											result.append("<U2000U2BFF>"      )
																						else:
																											for i in wd.encode("utf-8"      ):
																																result.append("<|byte%d|>" % i      )
																						SCREAMING_SNAKE_CASE    			=       end
												return result





							def 	__snake_case(						self   :					Optional[int]	,							_UpperCamelCase   :					str	,							_UpperCamelCase   :					Any="\n"      )					->				Any:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       []
												SCREAMING_SNAKE_CASE    			=       []
												SCREAMING_SNAKE_CASE    			=       self.ids_to_tokens[index][0]
												if word[:6] == "<|byte" and word[-2:] == "|>":
																	byte_tokens.append(int(word[6:-2]      )      )
												else:
																	if len(_UpperCamelCase      ) > 0:
																						words.append(bytearray(_UpperCamelCase      ).decode("utf-8"	,							errors="replace"      )      )
																						SCREAMING_SNAKE_CASE    			=       []
																	if word[:7] == "<|emoji" and word[-2:] == "|>":
																						words.append(self.emoji["emoji_inv"][word]      )
																	elif word == "<SP>":
																						words.append(" "      )
																	elif word == "<BR>":
																						words.append(_UpperCamelCase      )
																	elif word == "<TAB>":
																						words.append("\t"      )
																	elif word == "<BLOCK>":
																						words.append("▀"      )
																	elif word == "<KIGOU>":
																						words.append("ǀ"      )
																	elif word == "<U2000U2BFF>":
																						words.append("‖"      )
																	else:
																						words.append(_UpperCamelCase      )
												if len(_UpperCamelCase      ) > 0:
																	words.append(bytearray(_UpperCamelCase      ).decode("utf-8"	,							errors="replace"      )      )
												SCREAMING_SNAKE_CASE    			=       "".join(_UpperCamelCase      )
												return text





from __future__ import annotations

import math





def 	__lowerCamelCase							(UpperCAmelCase__     :							int  ):

					if 1 < number < 4:
										# 2 and 3 are primes
										return True
					elif number < 2 or number % 2 == 0 or number % 3 == 0:
										# Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
										return False

					# All primes number are in format of 6k +/- 1
					for i in range(5      , int(math.sqrt(UpperCAmelCase__  ) + 1  )      , 6  ):
										if number % i == 0 or number % (i + 2) == 0:
															return False
					return True


_lowerCamelCase					:   Tuple							=		[num for num in range(3, 10_00_01, 2) if not is_prime(num)]





def 	__lowerCamelCase							(UpperCAmelCase__     :							int  ):
					if not isinstance(UpperCAmelCase__      , UpperCAmelCase__  ):
										raise ValueError("n must be an integer"  )
					if n <= 0:
										raise ValueError("n must be >= 0"  )

					SCREAMING_SNAKE_CASE    			=       []
					for num in range(len(UpperCAmelCase__  )  ):
										SCREAMING_SNAKE_CASE    			=       0
										while 2 * i * i <= odd_composites[num]:
															SCREAMING_SNAKE_CASE    			=       odd_composites[num] - 2 * i * i
															if is_prime(UpperCAmelCase__  ):
																				break
															i += 1
										else:
															list_nums.append(odd_composites[num]  )
															if len(UpperCAmelCase__  ) == n:
																				return list_nums

					return []





def 	__lowerCamelCase							():
					return compute_nums(1  )[0]


if __name__ == "__main__":
							print(f"""{solution() = }""")




