






"""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


__a							:						Tuple   							=			logging.get_logger(__name__)

__a							:						Tuple   							=			{
    'vocab_file': 'vocab.json',
    'merges_file': 'merges.txt',
}

__a							:						List[str]   							=			{
    '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',
    },
}

__a							:						int   							=			{
    'Salesforce/codegen-350M-mono': 2048,
}





@lru_cache()
def 							SCREAMING_SNAKE_CASE							(   ):
					a__ 							=	(
					    list(range(ord('''!''')			,  ord('''~''') + 1)) + list(range(ord('''¡''')			,  ord('''¬''') + 1)) + list(range(ord('''®''')			,  ord('''ÿ''') + 1))
					)
					a__ 							=	bs[:]
					a__ 							=	0
					for b in range(2**8):
										if b not in bs:
															bs.append(lowerCamelCase_)
															cs.append(2**8 + n)
															n += 1
					a__ 							=	[chr(lowerCamelCase_) for n in cs]
					return dict(zip(lowerCamelCase_			,  lowerCamelCase_))





def 							SCREAMING_SNAKE_CASE							(   lowerCamelCase_):
					a__ 							=	set()
					a__ 							=	word[0]
					for char in word[1:]:
										pairs.add((prev_char, char))
										a__ 							=	char
					return pairs







class 							_SCREAMING_SNAKE_CASE    (	__snake_case				):





							"""simple docstring"""





							_SCREAMING_SNAKE_CASE     =VOCAB_FILES_NAMES
							_SCREAMING_SNAKE_CASE     =PRETRAINED_VOCAB_FILES_MAP
							_SCREAMING_SNAKE_CASE     =PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
							_SCREAMING_SNAKE_CASE     =['input_ids', 'attention_mask']




							def __init__( self:  int					,		__A:  Optional[Any]					,		__A:  Union[str, Any]					,		__A:  Any="replace"					,		__A:  List[str]="<|endoftext|>"					,		__A:  Optional[Any]="<|endoftext|>"					,		__A:  Optional[int]="<|endoftext|>"					,		__A:  Optional[int]=None					,		__A:  str=False					,		__A:  Optional[int]=False					,		**__A:  Optional[int]					,		):

												'''simple docstring'''

												a__ 							=	AddedToken(__A					,		lstrip=__A					,		rstrip=__A     ) if isinstance(__A					,		__A     ) else bos_token
												a__ 							=	AddedToken(__A					,		lstrip=__A					,		rstrip=__A     ) if isinstance(__A					,		__A     ) else eos_token
												a__ 							=	AddedToken(__A					,		lstrip=__A					,		rstrip=__A     ) if isinstance(__A					,		__A     ) else unk_token
												a__ 							=	AddedToken(__A					,		lstrip=__A					,		rstrip=__A     ) if isinstance(__A					,		__A     ) else pad_token
												super().__init__(
												    errors=__A					,		unk_token=__A					,		bos_token=__A					,		eos_token=__A					,		pad_token=__A					,		add_prefix_space=__A					,		add_bos_token=__A					,		**__A					,		)
												a__ 							=	add_bos_token

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

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




							@property
							def 			lowercase		( self:  Tuple     ):

												'''simple docstring'''

												return len(self.encoder     )




							def 			lowercase		( self:  List[str]     ):

												'''simple docstring'''

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




							def 			lowercase		( self:  Union[str, Any]					,		__A:  Any     ):

												'''simple docstring'''

												if token in self.cache:
																	return self.cache[token]
												a__ 							=	tuple(__A     )
												a__ 							=	get_pairs(__A     )

												if not pairs:
																	return token

												while True:
																	a__ 							=	min(__A					,		key=lambda __A     : self.bpe_ranks.get(__A					,		float('''inf'''     )     )     )
																	if bigram not in self.bpe_ranks:
																						break
																	a__							,a__ 							=	bigram
																	a__ 							=	[]
																	a__ 							=	0
																	while i < len(__A     ):
																						try:
																											a__ 							=	word.index(__A					,		__A     )
																						except ValueError:
																											new_word.extend(word[i:]     )
																											break
																						else:
																											new_word.extend(word[i:j]     )
																											a__ 							=	j

																						if word[i] == first and i < len(__A     ) - 1 and word[i + 1] == second:
																											new_word.append(first + second     )
																											i += 2
																						else:
																											new_word.append(word[i]     )
																											i += 1
																	a__ 							=	tuple(__A     )
																	a__ 							=	new_word
																	if len(__A     ) == 1:
																						break
																	else:
																						a__ 							=	get_pairs(__A     )
												a__ 							=	''' '''.join(__A     )
												a__ 							=	word
												return word




							def 			lowercase		( self:  List[Any]					,		__A:  List[Any]					,		__A:  Tuple=None     ):

												'''simple docstring'''

												if self.add_bos_token:
																	a__ 							=	[self.bos_token_id]
												else:
																	a__ 							=	[]

												a__ 							=	bos_token_ids + token_ids_a

												if token_ids_a is None:
																	return output

												return output + bos_token_ids + token_ids_a




							def 			lowercase		( self:  Dict					,		__A:  int     ):

												'''simple docstring'''

												a__ 							=	[]
												for token in re.findall(self.pat					,		__A     ):
																	a__ 							=	''''''.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(__A     ).split(''' '''     )     )
												return bpe_tokens




							def 			lowercase		( self:  Optional[int]					,		__A:  int     ):

												'''simple docstring'''

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




							def 			lowercase		( self:  List[str]					,		__A:  int     ):

												'''simple docstring'''

												return self.decoder.get(__A     )




							def 			lowercase		( self:  Union[str, Any]					,		__A:  Dict     ):

												'''simple docstring'''

												a__ 							=	''''''.join(__A     )
												a__ 							=	bytearray([self.byte_decoder[c] for c in text]     ).decode('''utf-8'''					,		errors=self.errors     )
												return text




							def 			lowercase		( self:  Tuple					,		__A:  str					,		__A:  Optional[str] = None     ):

												'''simple docstring'''

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

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

												a__ 							=	0
												with open(__A					,		'''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 __A     : 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!'''     )
																											a__ 							=	token_index
																						writer.write(''' '''.join(__A     ) + '''\n'''     )
																						index += 1

												return vocab_file, merge_file




							def 			lowercase		( self:  List[str]					,		__A:  List[str]					,		__A:  Union[str, Any]=False					,		**__A:  Optional[Any]     ):

												'''simple docstring'''

												a__ 							=	kwargs.pop('''add_prefix_space'''					,		self.add_prefix_space     )
												if is_split_into_words or add_prefix_space:
																	a__ 							=	''' ''' + text
												return (text, kwargs)




							def 			lowercase		( self:  Optional[Any]					,		__A:  Union[int, List[int], "np.ndarray", "torch.Tensor", "tf.Tensor"]					,		__A:  bool = False					,		__A:  bool = None					,		__A:  Optional[List[str]] = None					,		**__A:  Optional[Any]					,		):

												'''simple docstring'''

												a__ 							=	super()._decode(
												    token_ids=__A					,		skip_special_tokens=__A					,		clean_up_tokenization_spaces=__A					,		**__A					,		)

												if truncate_before_pattern is not None and len(__A     ) > 0:
																	a__ 							=	self.truncate(__A					,		__A     )

												return decoded_text





							def 			lowercase		( self:  str					,		__A:  Dict					,		__A:  int     ):

												'''simple docstring'''

												def find_re(__A:  Tuple					,		__A:  Optional[int]					,		__A:  Optional[int]     ):
																	a__ 							=	pattern.search(__A					,		__A     )
																	return m.start() if m else -1

												a__ 							=	[re.compile(__A					,		re.MULTILINE     ) for pattern in truncate_before_pattern]

												a__ 							=	list(re.finditer('''^print'''					,		__A					,		re.MULTILINE     )     )

												if len(__A     ) > 1:
																	a__ 							=	completion[: prints[1].start()]

												a__ 							=	list(re.finditer('''^def'''					,		__A					,		re.MULTILINE     )     )

												if len(__A     ) > 1:
																	a__ 							=	completion[: defs[1].start()]

												a__ 							=	0

												a__ 							=	[
												    pos for pos in [find_re(__A					,		__A					,		__A     ) for terminal in terminals] if pos != -1
												]

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










"""simple docstring"""







from itertools import combinations, product





def 							SCREAMING_SNAKE_CASE							(   lowerCamelCase_			,  lowerCamelCase_			,  lowerCamelCase_			,  lowerCamelCase_):
					if xa == ya == 0 or xa == ya == 0:
										return False
					a__ 							=	xa * xa + ya * ya
					a__ 							=	xa * xa + ya * ya
					a__ 							=	(xa - xa) * (xa - xa) + (ya - ya) * (ya - ya)
					return (
					    a_square + b_square == c_square
					    or a_square + c_square == b_square
					    or b_square + c_square == a_square
					)





def 							SCREAMING_SNAKE_CASE							(   lowerCamelCase_ = 50):
					return sum(
					    1
					    for pta, pta in combinations(product(range(limit + 1)			,  repeat=2)			,  2)
					    if is_right(*lowerCamelCase_			,  *lowerCamelCase_))


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


