

'''simple docstring'''







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						    =      logging.get_logger(__name__)

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

__lowerCamelCase						    =      {
    '''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						    =      {
    '''abeja/gpt-neox-japanese-2.7b''': 2048,
}
def  UpperCAmelCase__      ( UpperCAmelCase__,    UpperCAmelCase__			)     ->     List[str]:
       with open(UpperCAmelCase__,    """r""",    encoding="""utf-8"""			) as f:
              A_		   = json.loads(f.read()			)

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

       return vocab, raw_vocab, ids_to_tokens, emoji


class    A__ ( _snake_case     ):
    lowercase		   =						VOCAB_FILES_NAMES
    lowercase		   =						PRETRAINED_VOCAB_FILES_MAP
    lowercase		   =						PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
    lowercase		   =						["input_ids", "attention_mask"]



    def __init__(   self						,			UpperCamelCase__						,			UpperCamelCase__						,			UpperCamelCase__="<|endoftext|>"						,			UpperCamelCase__="<|endoftext|>"						,			UpperCamelCase__="<|startoftext|>"						,			UpperCamelCase__="<|endoftext|>"						,			UpperCamelCase__=False						,			**UpperCamelCase__						,			)  -> Dict:





           '''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)`"""    )
           A_		   = do_clean_text
           A_   ,     A_   ,     A_   ,     A_		   = load_vocab_and_emoji(UpperCamelCase__						,			UpperCamelCase__    )
           A_		   = SubWordJapaneseTokenizer(
               vocab=self.vocab						,			ids_to_tokens=self.ids_to_tokens						,			emoji=self.emoji    )



    @property
    def    snake_case_     (   self    )  -> Optional[Any]:





           '''simple docstring'''
           # self.vocab contains support for character fluctuation unique to Japanese, and has a large number of vocab
           return len(self.raw_vocab    )



    def    snake_case_     (   self    )  -> List[Any]:





           '''simple docstring'''
           return dict(self.raw_vocab						,			**self.added_tokens_encoder    )



    def    snake_case_     (   self						,			UpperCamelCase__    )  -> Any:





           '''simple docstring'''
           return self.subword_tokenizer.tokenize(UpperCamelCase__						,			clean=self.do_clean_text    )



    def    snake_case_     (   self						,			UpperCamelCase__    )  -> Optional[int]:





           '''simple docstring'''
           return self.vocab.get(UpperCamelCase__						,			self.vocab.get(self.unk_token    )    )



    def    snake_case_     (   self						,			UpperCamelCase__    )  -> Tuple:





           '''simple docstring'''
           return self.subword_tokenizer.convert_id_to_token(UpperCamelCase__    )



    def    snake_case_     (   self						,			UpperCamelCase__    )  -> List[Any]:





           '''simple docstring'''
           A_		   = """""".join(UpperCamelCase__    ).strip()
           return out_string



    def    snake_case_     (   self						,			UpperCamelCase__    )  -> List[int]:





           '''simple docstring'''
           A_		   = []
           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:
                  A_		   = input_ids[-self.model_max_length :]
           return input_ids







    def    snake_case_     (   self						,			UpperCamelCase__						,			UpperCamelCase__ = None    )  -> Tuple[str]:





           '''simple docstring'''
           A_		   = 0
           if os.path.isdir(UpperCamelCase__    ):
                  A_		   = os.path.join(
                      UpperCamelCase__						,			(filename_prefix + """-""" if filename_prefix else """""") + VOCAB_FILES_NAMES["""vocab_file"""]    )
                  A_		   = os.path.join(
                      UpperCamelCase__						,			(filename_prefix + """-""" if filename_prefix else """""") + VOCAB_FILES_NAMES["""emoji_file"""]    )
           else:
                  A_		   = (
                      (filename_prefix + """-""" if filename_prefix else """""") + save_directory + VOCAB_FILES_NAMES["""vocab_file"""]
                  )
                  A_		   = (
                      (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!"""    )
                                A_		   = 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    A__ ( _snake_case     ):



    def __init__(   self						,			UpperCamelCase__						,			UpperCamelCase__						,			UpperCamelCase__    )  -> str:





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



    def __len__(   self    )  -> int:





           '''simple docstring'''
           return len(self.ids_to_tokens    )



    def    snake_case_     (   self						,			UpperCamelCase__    )  -> Tuple:





           '''simple docstring'''
           A_		   = self.content_repattera.sub("""<URL>"""						,			UpperCamelCase__    )
           A_		   = self.content_repattera.sub("""<EMAIL>"""						,			UpperCamelCase__    )
           A_		   = self.content_repattera.sub("""<TEL>"""						,			UpperCamelCase__    )
           A_		   = self.content_repattera.sub("""<DATE>"""						,			UpperCamelCase__    )
           A_		   = self.content_repattera.sub("""<DATE>"""						,			UpperCamelCase__    )
           A_		   = self.content_repattera.sub("""<PRICE>"""						,			UpperCamelCase__    )
           A_		   = content.translate(self.content_transa    )
           while "<BLOCK><BLOCK>" in content:
                  A_		   = content.replace("""<BLOCK><BLOCK>"""						,			"""<BLOCK>"""    )
           return content



    def    snake_case_     (   self						,			UpperCamelCase__						,			UpperCamelCase__=False    )  -> Optional[Any]:





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

           def check_simbol(UpperCamelCase__    ):
                  A_		   = x.encode()
                  if len(UpperCamelCase__    ) == 1 and len(UpperCamelCase__    ) == 2:
                         A_		   = (int(e[0]    ) << 8) + int(e[1]    )
                         if (
                             (c >= 0XC_2A1 and c <= 0XC_2BF)
                             or (c >= 0XC_780 and c <= 0XC_783)
                             or (c >= 0XC_AB9 and c <= 0XC_BBF)
                             or (c >= 0XC_C80 and c <= 0XC_DA2)
                         ):
                                return True
                  return False

           def checkuae(UpperCamelCase__    ):
                  A_		   = x.encode()
                  if len(UpperCamelCase__    ) == 1 and len(UpperCamelCase__    ) == 3:
                         A_		   = (int(e[0]    ) << 16) + (int(e[1]    ) << 8) + int(e[2]    )
                         if c >= 0XE28_080 and c <= 0XE2B_07F:
                                return True
                  return False

           A_		   = 0
           A_		   = []
           while pos < len(UpperCamelCase__    ):
                  A_		   = min(len(UpperCamelCase__    )						,			pos + self.maxlen + 1    ) if text[pos] == """<""" else pos + 3
                  A_		   = []  # (token_id, token, pos)
                  for e in range(UpperCamelCase__						,			UpperCamelCase__						,			-1    ):
                         A_		   = text[pos:e]
                         if wd in self.vocab:
                                if wd[0] == "<" and len(UpperCamelCase__    ) > 2:
                                       A_		   = [(self.vocab[wd], wd, e)]
                                       break
                                else:
                                       candidates.append((self.vocab[wd], wd, e)    )
                  if len(UpperCamelCase__    ) > 0:
                         # the smallest token_id is adopted
                         A_   ,     A_   ,     A_		   = sorted(UpperCamelCase__						,			key=lambda UpperCamelCase__    : x[0]    )[0]
                         result.append(UpperCamelCase__    )
                         A_		   = e
                  else:
                         A_		   = pos + 1
                         A_		   = 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    )
                         A_		   = end
           return result







    def    snake_case_     (   self						,			UpperCamelCase__						,			UpperCamelCase__="\n"    )  -> int:





           '''simple docstring'''
           A_		   = []
           A_		   = []
           A_		   = 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"""    )    )
                         A_		   = []
                  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"""    )    )
           A_		   = """""".join(UpperCamelCase__    )
           return text



'''simple docstring'''







import sys

__lowerCamelCase						    =      (
    '''73167176531330624919225119674426574742355349194934'''
    '''96983520312774506326239578318016984801869478851843'''
    '''85861560789112949495459501737958331952853208805511'''
    '''12540698747158523863050715693290963295227443043557'''
    '''66896648950445244523161731856403098711121722383113'''
    '''62229893423380308135336276614282806444486645238749'''
    '''30358907296290491560440772390713810515859307960866'''
    '''70172427121883998797908792274921901699720888093776'''
    '''65727333001053367881220235421809751254540594752243'''
    '''52584907711670556013604839586446706324415722155397'''
    '''53697817977846174064955149290862569321978468622482'''
    '''83972241375657056057490261407972968652414535100474'''
    '''82166370484403199890008895243450658541227588666881'''
    '''16427171479924442928230863465674813919123162824586'''
    '''17866458359124566529476545682848912883142607690042'''
    '''24219022671055626321111109370544217506941658960408'''
    '''07198403850962455444362981230987879927244284909188'''
    '''84580156166097919133875499200524063689912560717606'''
    '''05886116467109405077541002256983155200055935729725'''
    '''71636269561882670428252483600823257530420752963450'''
)
def  UpperCAmelCase__      ( UpperCAmelCase__ = N			)     ->     int:
       A_		   = -sys.maxsize - 1
       for i in range(len(UpperCAmelCase__			) - 12			):
              A_		   = 1
              for j in range(13			):
                     product *= int(n[i + j]			)
              if product > largest_product:
                     A_		   = product
       return largest_product


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