
'''simple docstring'''







import json
import os
from functools import lru_cache
from typing import TYPE_CHECKING, List, Optional, Tuple, Union

import numpy as np
import regex as re

from ...utils import is_tf_available, is_torch_available, logging


if TYPE_CHECKING:
							if is_torch_available():
														import torch
							if is_tf_available():
														import tensorflow as tf

from ...tokenization_utils import AddedToken, PreTrainedTokenizer


_lowercase				:						Any												= logging.get_logger(__name__)

_lowercase				:						Any												= {
    "vocab_file": "vocab.json",
    "merges_file": "merges.txt",
}

_lowercase				:						int												= {
    "vocab_file": {
        "Salesforce/codegen-350M-mono": "https://huggingface.co/Salesforce/codegen-350M-mono/resolve/main/vocab.json",
    },
    "merges_file": {
        "Salesforce/codegen-350M-mono": "https://huggingface.co/Salesforce/codegen-350M-mono/resolve/main/merges.txt",
    },
}

_lowercase				:						Optional[Any]												= {
    "Salesforce/codegen-350M-mono": 2_0_4_8,
}
@lru_cache()
def       snake_case_	(       ):



						"""simple docstring"""





						lowercase_			:  Optional[Any]									= (
						    list(range(ord('''!'''							)   ,   ord('''~'''							) + 1							)							) + list(range(ord('''¡'''							)   ,   ord('''¬'''							) + 1							)							) + list(range(ord('''®'''							)   ,   ord('''ÿ'''							) + 1							)							)
						)
						lowercase_			:  Any									= bs[:]
						lowercase_			:  Tuple									= 0
						for b in range(2**8							):
												if b not in bs:
																		bs.append(__SCREAMING_SNAKE_CASE							)
																		cs.append(2**8 + n							)
																		n += 1
						lowercase_			:  str									= [chr(__SCREAMING_SNAKE_CASE							) for n in cs]
						return dict(zip(__SCREAMING_SNAKE_CASE   ,   __SCREAMING_SNAKE_CASE							)							)
def       snake_case_	(       __SCREAMING_SNAKE_CASE      :				Optional[int]							):



						"""simple docstring"""





						lowercase_			:  Optional[int]									= set()
						lowercase_			:  Any									= word[0]
						for char in word[1:]:
												pairs.add((prev_char, char)							)
												lowercase_			:  Union[str, Any]									= char
						return pairs






class 				lowerCAmelCase__     (						lowerCamelCase_  ):
					lowerCAmelCase_       =  VOCAB_FILES_NAMES
					lowerCAmelCase_       =  PRETRAINED_VOCAB_FILES_MAP
					lowerCAmelCase_       =  PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
					lowerCAmelCase_       =  ['''input_ids''', '''attention_mask''']






					def __init__(     self       ,							__SCREAMING_SNAKE_CASE       ,							__SCREAMING_SNAKE_CASE       ,							__SCREAMING_SNAKE_CASE="replace"       ,							__SCREAMING_SNAKE_CASE="<|endoftext|>"       ,							__SCREAMING_SNAKE_CASE="<|endoftext|>"       ,							__SCREAMING_SNAKE_CASE="<|endoftext|>"       ,							__SCREAMING_SNAKE_CASE=None       ,							__SCREAMING_SNAKE_CASE=False       ,							__SCREAMING_SNAKE_CASE=False       ,							**__SCREAMING_SNAKE_CASE       ,							):


											"""simple docstring"""





											lowercase_			:  List[Any]									= AddedToken(__SCREAMING_SNAKE_CASE       ,							lstrip=__SCREAMING_SNAKE_CASE       ,							rstrip=__SCREAMING_SNAKE_CASE	) if isinstance(__SCREAMING_SNAKE_CASE       ,							__SCREAMING_SNAKE_CASE	) else bos_token
											lowercase_			:  Optional[Any]									= AddedToken(__SCREAMING_SNAKE_CASE       ,							lstrip=__SCREAMING_SNAKE_CASE       ,							rstrip=__SCREAMING_SNAKE_CASE	) if isinstance(__SCREAMING_SNAKE_CASE       ,							__SCREAMING_SNAKE_CASE	) else eos_token
											lowercase_			:  Union[str, Any]									= AddedToken(__SCREAMING_SNAKE_CASE       ,							lstrip=__SCREAMING_SNAKE_CASE       ,							rstrip=__SCREAMING_SNAKE_CASE	) if isinstance(__SCREAMING_SNAKE_CASE       ,							__SCREAMING_SNAKE_CASE	) else unk_token
											lowercase_			:  Tuple									= AddedToken(__SCREAMING_SNAKE_CASE       ,							lstrip=__SCREAMING_SNAKE_CASE       ,							rstrip=__SCREAMING_SNAKE_CASE	) if isinstance(__SCREAMING_SNAKE_CASE       ,							__SCREAMING_SNAKE_CASE	) else pad_token
											super().__init__(
											    errors=__SCREAMING_SNAKE_CASE       ,							unk_token=__SCREAMING_SNAKE_CASE       ,							bos_token=__SCREAMING_SNAKE_CASE       ,							eos_token=__SCREAMING_SNAKE_CASE       ,							pad_token=__SCREAMING_SNAKE_CASE       ,							add_prefix_space=__SCREAMING_SNAKE_CASE       ,							add_bos_token=__SCREAMING_SNAKE_CASE       ,							**__SCREAMING_SNAKE_CASE       ,							)
											lowercase_			:  Optional[int]									= add_bos_token

											with open(__SCREAMING_SNAKE_CASE       ,							encoding='''utf-8'''	) as vocab_handle:
																	lowercase_			:  Optional[int]									= json.load(__SCREAMING_SNAKE_CASE	)
											lowercase_			:  str									= {v: k for k, v in self.encoder.items()}
											lowercase_			:  Dict									= errors  # how to handle errors in decoding
											lowercase_			:  List[str]									= bytes_to_unicode()
											lowercase_			:  Dict									= {v: k for k, v in self.byte_encoder.items()}
											with open(__SCREAMING_SNAKE_CASE       ,							encoding='''utf-8'''	) as merges_handle:
																	lowercase_			:  Dict									= merges_handle.read().split('''\n'''	)[1:-1]
											lowercase_			:  Tuple									= [tuple(merge.split()	) for merge in bpe_merges]
											lowercase_			:  str									= dict(zip(__SCREAMING_SNAKE_CASE       ,							range(len(__SCREAMING_SNAKE_CASE	)	)	)	)
											lowercase_			:  Tuple									= {}
											lowercase_			:  Dict									= add_prefix_space

											# Should have added re.IGNORECASE so BPE merges can happen for capitalized versions of contractions
											lowercase_			:  Optional[int]									= re.compile(R'''\'s|\'t|\'re|\'ve|\'m|\'ll|\'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+'''	)






					@property
					def 			_snake_case					(     self	):


											"""simple docstring"""





											return len(self.encoder	)






					def 			_snake_case					(     self	):


											"""simple docstring"""





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






					def 			_snake_case					(     self       ,							__SCREAMING_SNAKE_CASE	):


											"""simple docstring"""





											if token in self.cache:
																	return self.cache[token]
											lowercase_			:  Optional[int]									= tuple(__SCREAMING_SNAKE_CASE	)
											lowercase_			:  Optional[Any]									= get_pairs(__SCREAMING_SNAKE_CASE	)

											if not pairs:
																	return token

											while True:
																	lowercase_			:  int									= min(__SCREAMING_SNAKE_CASE       ,							key=lambda __SCREAMING_SNAKE_CASE	: self.bpe_ranks.get(__SCREAMING_SNAKE_CASE       ,							float('''inf'''	)	)	)
																	if bigram not in self.bpe_ranks:
																							break
																	lowercase_		,				lowercase_			:  Optional[Any]									= bigram
																	lowercase_			:  Dict									= []
																	lowercase_			:  List[str]									= 0
																	while i < len(__SCREAMING_SNAKE_CASE	):
																							try:
																													lowercase_			:  Tuple									= word.index(__SCREAMING_SNAKE_CASE       ,							__SCREAMING_SNAKE_CASE	)
																							except ValueError:
																													new_word.extend(word[i:]	)
																													break
																							else:
																													new_word.extend(word[i:j]	)
																													lowercase_			:  Any									= j

																							if word[i] == first and i < len(__SCREAMING_SNAKE_CASE	) - 1 and word[i + 1] == second:
																													new_word.append(first + second	)
																													i += 2
																							else:
																													new_word.append(word[i]	)
																													i += 1
																	lowercase_			:  Union[str, Any]									= tuple(__SCREAMING_SNAKE_CASE	)
																	lowercase_			:  Optional[int]									= new_word
																	if len(__SCREAMING_SNAKE_CASE	) == 1:
																							break
																	else:
																							lowercase_			:  Optional[Any]									= get_pairs(__SCREAMING_SNAKE_CASE	)
											lowercase_			:  List[str]									= ''' '''.join(__SCREAMING_SNAKE_CASE	)
											lowercase_			:  Any									= word
											return word






					def 			_snake_case					(     self       ,							__SCREAMING_SNAKE_CASE       ,							__SCREAMING_SNAKE_CASE=None	):


											"""simple docstring"""





											if self.add_bos_token:
																	lowercase_			:  Union[str, Any]									= [self.bos_token_id]
											else:
																	lowercase_			:  Any									= []

											lowercase_			:  Dict									= bos_token_ids + token_ids_a

											if token_ids_a is None:
																	return output

											return output + bos_token_ids + token_ids_a






					def 			_snake_case					(     self       ,							__SCREAMING_SNAKE_CASE	):


											"""simple docstring"""





											lowercase_			:  int									= []
											for token in re.findall(self.pat       ,							__SCREAMING_SNAKE_CASE	):
																	lowercase_			:  Optional[int]									= ''''''.join(
																	    self.byte_encoder[b] for b in token.encode('''utf-8'''	)	)  # Maps all our bytes to unicode strings, avoiding control tokens of the BPE (spaces in our case)
																	bpe_tokens.extend(bpe_token for bpe_token in self.bpe(__SCREAMING_SNAKE_CASE	).split(''' '''	)	)
											return bpe_tokens






					def 			_snake_case					(     self       ,							__SCREAMING_SNAKE_CASE	):


											"""simple docstring"""





											return self.encoder.get(__SCREAMING_SNAKE_CASE       ,							self.encoder.get(self.unk_token	)	)






					def 			_snake_case					(     self       ,							__SCREAMING_SNAKE_CASE	):


											"""simple docstring"""





											return self.decoder.get(__SCREAMING_SNAKE_CASE	)






					def 			_snake_case					(     self       ,							__SCREAMING_SNAKE_CASE	):


											"""simple docstring"""





											lowercase_			:  str									= ''''''.join(__SCREAMING_SNAKE_CASE	)
											lowercase_			:  List[Any]									= bytearray([self.byte_decoder[c] for c in text]	).decode('''utf-8'''       ,							errors=self.errors	)
											return text






					def 			_snake_case					(     self       ,							__SCREAMING_SNAKE_CASE       ,							__SCREAMING_SNAKE_CASE = None	):


											"""simple docstring"""





											if not os.path.isdir(__SCREAMING_SNAKE_CASE	):
																	logger.error(F'''Vocabulary path ({save_directory}) should be a directory'''	)
																	return
											lowercase_			:  int									= os.path.join(
											    __SCREAMING_SNAKE_CASE       ,							(filename_prefix + '''-''' if filename_prefix else '''''') + VOCAB_FILES_NAMES['''vocab_file''']	)
											lowercase_			:  Union[str, Any]									= os.path.join(
											    __SCREAMING_SNAKE_CASE       ,							(filename_prefix + '''-''' if filename_prefix else '''''') + VOCAB_FILES_NAMES['''merges_file''']	)

											with open(__SCREAMING_SNAKE_CASE       ,							'''w'''       ,							encoding='''utf-8'''	) as f:
																	f.write(json.dumps(self.encoder       ,							indent=2       ,							sort_keys=__SCREAMING_SNAKE_CASE       ,							ensure_ascii=__SCREAMING_SNAKE_CASE	) + '''\n'''	)

											lowercase_			:  Any									= 0
											with open(__SCREAMING_SNAKE_CASE       ,							'''w'''       ,							encoding='''utf-8'''	) as writer:
																	writer.write('''#version: 0.2\n'''	)
																	for bpe_tokens, token_index in sorted(self.bpe_ranks.items()       ,							key=lambda __SCREAMING_SNAKE_CASE	: kv[1]	):
																							if index != token_index:
																													logger.warning(
																													    F'''Saving vocabulary to {merge_file}: BPE merge indices are not consecutive.'''
																													    ''' Please check that the tokenizer is not corrupted!'''	)
																													lowercase_			:  Optional[int]									= token_index
																							writer.write(''' '''.join(__SCREAMING_SNAKE_CASE	) + '''\n'''	)
																							index += 1

											return vocab_file, merge_file






					def 			_snake_case					(     self       ,							__SCREAMING_SNAKE_CASE       ,							__SCREAMING_SNAKE_CASE=False       ,							**__SCREAMING_SNAKE_CASE	):


											"""simple docstring"""





											lowercase_			:  List[Any]									= kwargs.pop('''add_prefix_space'''       ,							self.add_prefix_space	)
											if is_split_into_words or add_prefix_space:
																	lowercase_			:  int									= ''' ''' + text
											return (text, kwargs)






					def 			_snake_case					(     self       ,							__SCREAMING_SNAKE_CASE       ,							__SCREAMING_SNAKE_CASE = False       ,							__SCREAMING_SNAKE_CASE = None       ,							__SCREAMING_SNAKE_CASE = None       ,							**__SCREAMING_SNAKE_CASE       ,							):


											"""simple docstring"""





											lowercase_			:  List[str]									= super()._decode(
											    token_ids=__SCREAMING_SNAKE_CASE       ,							skip_special_tokens=__SCREAMING_SNAKE_CASE       ,							clean_up_tokenization_spaces=__SCREAMING_SNAKE_CASE       ,							**__SCREAMING_SNAKE_CASE       ,							)

											if truncate_before_pattern is not None and len(__SCREAMING_SNAKE_CASE	) > 0:
																	lowercase_			:  int									= self.truncate(__SCREAMING_SNAKE_CASE       ,							__SCREAMING_SNAKE_CASE	)

											return decoded_text






					def 			_snake_case					(     self       ,							__SCREAMING_SNAKE_CASE       ,							__SCREAMING_SNAKE_CASE	):


											"""simple docstring"""





											def find_re(__SCREAMING_SNAKE_CASE       ,							__SCREAMING_SNAKE_CASE       ,							__SCREAMING_SNAKE_CASE	):
																	lowercase_			:  List[str]									= pattern.search(__SCREAMING_SNAKE_CASE       ,							__SCREAMING_SNAKE_CASE	)
																	return m.start() if m else -1

											lowercase_			:  Tuple									= [re.compile(__SCREAMING_SNAKE_CASE       ,							re.MULTILINE	) for pattern in truncate_before_pattern]

											lowercase_			:  Dict									= list(re.finditer('''^print'''       ,							__SCREAMING_SNAKE_CASE       ,							re.MULTILINE	)	)

											if len(__SCREAMING_SNAKE_CASE	) > 1:
																	lowercase_			:  int									= completion[: prints[1].start()]

											lowercase_			:  List[str]									= list(re.finditer('''^def'''       ,							__SCREAMING_SNAKE_CASE       ,							re.MULTILINE	)	)

											if len(__SCREAMING_SNAKE_CASE	) > 1:
																	lowercase_			:  int									= completion[: defs[1].start()]

											lowercase_			:  Dict									= 0

											lowercase_			:  Optional[Any]									= [
											    pos for pos in [find_re(__SCREAMING_SNAKE_CASE       ,							__SCREAMING_SNAKE_CASE       ,							__SCREAMING_SNAKE_CASE	) for terminal in terminals] if pos != -1
											]

											if len(__SCREAMING_SNAKE_CASE	) > 0:
																	return completion[: min(__SCREAMING_SNAKE_CASE	)]
											else:
																	return completion





'''simple docstring'''







def       snake_case_	(       __SCREAMING_SNAKE_CASE      :				int = 998001							):



						"""simple docstring"""





						lowercase_			:  Dict									= 0
						for i in range(999   ,   99   ,   -1							):  # 3 digit numbers range from 999 down to 100
												for j in range(999   ,   99   ,   -1							):
																		lowercase_			:  int									= str(i * j							)
																		if product_string == product_string[::-1] and i * j < n:
																								lowercase_			:  str									= max(__SCREAMING_SNAKE_CASE   ,   i * j							)
						return answer


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



