


'''simple docstring'''
import os
import unicodedata
from shutil import copyfile
from typing import Any, Dict, List, Optional, Tuple

import sentencepiece as spm

from ...tokenization_utils import AddedToken, PreTrainedTokenizer
from ...utils import logging


lowerCAmelCase   : int             =				logging.get_logger(__name__)
lowerCAmelCase   : List[Any]             =				{"""vocab_file""": """spiece.model"""}

lowerCAmelCase   : List[str]             =				{
    """vocab_file""": {
        """albert-base-v1""": """https://huggingface.co/albert-base-v1/resolve/main/spiece.model""",
        """albert-large-v1""": """https://huggingface.co/albert-large-v1/resolve/main/spiece.model""",
        """albert-xlarge-v1""": """https://huggingface.co/albert-xlarge-v1/resolve/main/spiece.model""",
        """albert-xxlarge-v1""": """https://huggingface.co/albert-xxlarge-v1/resolve/main/spiece.model""",
        """albert-base-v2""": """https://huggingface.co/albert-base-v2/resolve/main/spiece.model""",
        """albert-large-v2""": """https://huggingface.co/albert-large-v2/resolve/main/spiece.model""",
        """albert-xlarge-v2""": """https://huggingface.co/albert-xlarge-v2/resolve/main/spiece.model""",
        """albert-xxlarge-v2""": """https://huggingface.co/albert-xxlarge-v2/resolve/main/spiece.model""",
    }
}

lowerCAmelCase   : int             =				{
    """albert-base-v1""": 5_1_2,
    """albert-large-v1""": 5_1_2,
    """albert-xlarge-v1""": 5_1_2,
    """albert-xxlarge-v1""": 5_1_2,
    """albert-base-v2""": 5_1_2,
    """albert-large-v2""": 5_1_2,
    """albert-xlarge-v2""": 5_1_2,
    """albert-xxlarge-v2""": 5_1_2,
}

lowerCAmelCase   : Dict             =				"""▁"""




class        _UpperCamelCase	(    SCREAMING_SNAKE_CASE):


				'''simple docstring'''


				_snake_case						       =				VOCAB_FILES_NAMES
				_snake_case						       =				PRETRAINED_VOCAB_FILES_MAP
				_snake_case						       =				PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES

				def __init__(     self							,      a_							,      a_=True							,      a_=True							,      a_=False							,      a_="[CLS]"							,      a_="[SEP]"							,      a_="<unk>"							,      a_="[SEP]"							,      a_="<pad>"							,      a_="[CLS]"							,      a_="[MASK]"							,      a_ = None							,      **a_							,      )    ->  None:
					# Mask token behave like a normal word, i.e. include the space before it and
					# is included in the raw text, there should be a match in a non-normalized sentence.
					lowercase						:		int   					=		(
					    AddedToken(a_							,      lstrip=a_							,      rstrip=a_							,      normalized=a_							)
					    if isinstance(a_							,      a_							)
					    else mask_token
					)

					lowercase						:		Any   					=		{} if sp_model_kwargs is None else sp_model_kwargs

					super().__init__(
					    do_lower_case=a_							,      remove_space=a_							,      keep_accents=a_							,      bos_token=a_							,      eos_token=a_							,      unk_token=a_							,      sep_token=a_							,      pad_token=a_							,      cls_token=a_							,      mask_token=a_							,      sp_model_kwargs=self.sp_model_kwargs							,      **a_							,      )

					lowercase						:		Dict   					=		do_lower_case
					lowercase						:		List[str]   					=		remove_space
					lowercase						:		Optional[int]   					=		keep_accents
					lowercase						:		Optional[int]   					=		vocab_file

					lowercase						:		Tuple   					=		spm.SentencePieceProcessor(**self.sp_model_kwargs							)
					self.sp_model.Load(a_							)

				@property
				def 	a__		(     self							)    ->  List[Any]:
					return len(self.sp_model							)

				def 	a__		(     self							)    ->  Any:
					lowercase						:		str   					=		{self.convert_ids_to_tokens(a_							): i for i in range(self.vocab_size							)}
					vocab.update(self.added_tokens_encoder							)
					return vocab

				def __getstate__(     self							)    ->  List[str]:
					lowercase						:		Union[str, Any]   					=		self.__dict__.copy()
					lowercase						:		Optional[Any]   					=		None
					return state

				def __setstate__(     self							,      a_							)    ->  Optional[int]:
					lowercase						:		int   					=		d

					# for backward compatibility
					if not hasattr(self							,      "sp_model_kwargs"							):
						lowercase						:		Any   					=		{}

					lowercase						:		Dict   					=		spm.SentencePieceProcessor(**self.sp_model_kwargs							)
					self.sp_model.Load(self.vocab_file							)

				def 	a__		(     self							,      a_							)    ->  List[str]:
					if self.remove_space:
						lowercase						:		List[Any]   					=		" ".join(inputs.strip().split()							)
					else:
						lowercase						:		int   					=		inputs
					lowercase						:		Dict   					=		outputs.replace("``"							,      "\""							).replace("''"							,      "\""							)

					if not self.keep_accents:
						lowercase						:		Tuple   					=		unicodedata.normalize("NFKD"							,      a_							)
						lowercase						:		str   					=		"".join([c for c in outputs if not unicodedata.combining(a_							)]							)
					if self.do_lower_case:
						lowercase						:		Optional[int]   					=		outputs.lower()

					return outputs

				def 	a__		(     self							,      a_							)    ->  List[str]:
					lowercase						:		Union[str, Any]   					=		self.preprocess_text(a_							)
					lowercase						:		Any   					=		self.sp_model.encode(a_							,      out_type=a_							)
					lowercase						:		int   					=		[]
					for piece in pieces:
						if len(a_							) > 1 and piece[-1] == str(","							) and piece[-2].isdigit():
							lowercase						:		Dict   					=		self.sp_model.EncodeAsPieces(piece[:-1].replace(a_							,      ""							)							)
							if piece[0] != SPIECE_UNDERLINE and cur_pieces[0][0] == SPIECE_UNDERLINE:
								if len(cur_pieces[0]							) == 1:
									lowercase						:		int   					=		cur_pieces[1:]
								else:
									lowercase						:		Optional[int]   					=		cur_pieces[0][1:]
							cur_pieces.append(piece[-1]							)
							new_pieces.extend(a_							)
						else:
							new_pieces.append(a_							)

					return new_pieces

				def 	a__		(     self							,      a_							)    ->  Optional[Any]:
					return self.sp_model.PieceToId(a_							)

				def 	a__		(     self							,      a_							)    ->  Optional[int]:
					return self.sp_model.IdToPiece(a_							)

				def 	a__		(     self							,      a_							)    ->  Union[str, Any]:
					lowercase						:		Any   					=		[]
					lowercase						:		Dict   					=		""
					lowercase						:		Optional[int]   					=		False
					for token in tokens:
						# make sure that special tokens are not decoded using sentencepiece model
						if token in self.all_special_tokens:
							if not prev_is_special:
								out_string += " "
							out_string += self.sp_model.decode(a_							) + token
							lowercase						:		Optional[Any]   					=		True
							lowercase						:		Any   					=		[]
						else:
							current_sub_tokens.append(a_							)
							lowercase						:		int   					=		False
					out_string += self.sp_model.decode(a_							)
					return out_string.strip()

				def 	a__		(     self							,      a_							,      a_ = None							)    ->  List[int]:
					lowercase						:		List[str]   					=		[self.sep_token_id]
					lowercase						:		Union[str, Any]   					=		[self.cls_token_id]
					if token_ids_a is None:
						return cls + token_ids_a + sep
					return cls + token_ids_a + sep + token_ids_a + sep

				def 	a__		(     self							,      a_							,      a_ = None							,      a_ = False							)    ->  List[int]:

					if already_has_special_tokens:
						return super().get_special_tokens_mask(
						    token_ids_a=a_							,      token_ids_a=a_							,      already_has_special_tokens=a_							)

					if token_ids_a is not None:
						return [1] + ([0] * len(a_							)) + [1] + ([0] * len(a_							)) + [1]
					return [1] + ([0] * len(a_							)) + [1]

				def 	a__		(     self							,      a_							,      a_ = None							)    ->  List[int]:
					lowercase						:		Optional[int]   					=		[self.sep_token_id]
					lowercase						:		Dict   					=		[self.cls_token_id]

					if token_ids_a is None:
						return len(cls + token_ids_a + sep							) * [0]
					return len(cls + token_ids_a + sep							) * [0] + len(token_ids_a + sep							) * [1]


				def 	a__		(     self							,      a_							,      a_ = None							)    ->  Tuple[str]:
					if not os.path.isdir(a_							):
						logger.error(F'''Vocabulary path ({save_directory}) should be a directory'''							)
						return
					lowercase						:		List[str]   					=		os.path.join(
					    a_							,      (filename_prefix + "-" if filename_prefix else "") + VOCAB_FILES_NAMES["vocab_file"]							)

					if os.path.abspath(self.vocab_file							) != os.path.abspath(a_							) and os.path.isfile(self.vocab_file							):
						copyfile(self.vocab_file							,      a_							)
					elif not os.path.isfile(self.vocab_file							):
						with open(a_							,      "wb"							) as fi:
							lowercase						:		Union[str, Any]   					=		self.sp_model.serialized_model_proto()
							fi.write(a_							)

					return (out_vocab_file,)






'''simple docstring'''
def 	_A  (       A							)  ->				list:

	if len(A							) <= 1:
		return [tuple(A							)]

	lowercase						:		Dict   					=		[]

	def generate(A							,A							):
		lowercase						:		List[Any]   					=		[0] * n
		res.append(tuple(A							)							)

		lowercase						:		Tuple   					=		0
		while i < n:
			if c[i] < i:
				if i % 2 == 0:
					lowercase					,		lowercase						:		List[Any]   					=		arr[i], arr[0]
				else:
					lowercase					,		lowercase						:		Optional[Any]   					=		arr[i], arr[c[i]]
				res.append(tuple(A							)							)
				c[i] += 1
				lowercase						:		Optional[Any]   					=		0
			else:
				lowercase						:		Any   					=		0
				i += 1

	generate(len(A							)							,A							)
	return res


if __name__ == "__main__":
					lowerCAmelCase   : Any             =				input("""Enter numbers separated by a comma:\n""").strip()
					lowerCAmelCase   : List[str]             =				[int(item) for item in user_input.split(""",""")]
					print(heaps(arr))


