"""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    :							List[str]													=						logging.get_logger(__name__)
__lowerCAmelCase    :							Any													=						{"vocab_file": "spiece.model"}

__lowerCAmelCase    :							Dict													=						{
    "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    :							Tuple													=						{
    "albert-base-v1": 5_12,
    "albert-large-v1": 5_12,
    "albert-xlarge-v1": 5_12,
    "albert-xxlarge-v1": 5_12,
    "albert-base-v2": 5_12,
    "albert-large-v2": 5_12,
    "albert-xlarge-v2": 5_12,
    "albert-xxlarge-v2": 5_12,
}

__lowerCAmelCase    :							Union[str, Any]													=						"▁"

class       a_      (     __UpperCamelCase			):
					UpperCamelCase_ :	List[str]			=    VOCAB_FILES_NAMES
					UpperCamelCase_ :	Dict			=    PRETRAINED_VOCAB_FILES_MAP
					UpperCamelCase_ :	str			=    PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES




					def __init__(	self						:     Tuple  ,						snake_case__						:     List[str]  ,						snake_case__						:     Optional[Any]=True  ,						snake_case__						:     Tuple=True  ,						snake_case__						:     str=False  ,						snake_case__						:     Optional[Any]="[CLS]"  ,						snake_case__						:     Optional[int]="[SEP]"  ,						snake_case__						:     List[str]="<unk>"  ,						snake_case__						:     Optional[int]="[SEP]"  ,						snake_case__						:     List[Any]="<pad>"  ,						snake_case__						:     Tuple="[CLS]"  ,						snake_case__						:     Optional[Any]="[MASK]"  ,						snake_case__						:     Optional[Dict[str, Any]] = None  ,						**snake_case__						:     Tuple  ,						):
							# 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.
							lowerCAmelCase__        =   (
							    AddedToken(snake_case__  ,						lstrip=snake_case__  ,						rstrip=snake_case__  ,						normalized=snake_case__     )
							    if isinstance(snake_case__  ,						snake_case__     )
							    else mask_token
							)

							lowerCAmelCase__        =   {} if sp_model_kwargs is None else sp_model_kwargs

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

							lowerCAmelCase__        =   do_lower_case
							lowerCAmelCase__        =   remove_space
							lowerCAmelCase__        =   keep_accents
							lowerCAmelCase__        =   vocab_file

							lowerCAmelCase__        =   spm.SentencePieceProcessor(**self.sp_model_kwargs     )
							self.sp_model.Load(snake_case__     )




					@property
					def 						_SCREAMING_SNAKE_CASE						(	self						:     Any     ):
							return len(self.sp_model     )




					def 						_SCREAMING_SNAKE_CASE						(	self						:     Dict     ):
							lowerCAmelCase__        =   {self.convert_ids_to_tokens(snake_case__     ): i for i in range(self.vocab_size     )}
							vocab.update(self.added_tokens_encoder     )
							return vocab




					def __getstate__(	self						:     Optional[int]     ):
							lowerCAmelCase__        =   self.__dict__.copy()
							lowerCAmelCase__        =   None
							return state




					def __setstate__(	self						:     Tuple  ,						snake_case__						:     Any     ):
							lowerCAmelCase__        =   d

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

							lowerCAmelCase__        =   spm.SentencePieceProcessor(**self.sp_model_kwargs     )
							self.sp_model.Load(self.vocab_file     )




					def 						_SCREAMING_SNAKE_CASE						(	self						:     List[str]  ,						snake_case__						:     Dict     ):
							if self.remove_space:
									lowerCAmelCase__        =   """ """.join(inputs.strip().split()     )
							else:
									lowerCAmelCase__        =   inputs
							lowerCAmelCase__        =   outputs.replace("""``"""  ,						"""\""""     ).replace("""''"""  ,						"""\""""     )

							if not self.keep_accents:
									lowerCAmelCase__        =   unicodedata.normalize("""NFKD"""  ,						snake_case__     )
									lowerCAmelCase__        =   """""".join([c for c in outputs if not unicodedata.combining(snake_case__     )]     )
							if self.do_lower_case:
									lowerCAmelCase__        =   outputs.lower()

							return outputs




					def 						_SCREAMING_SNAKE_CASE						(	self						:     Tuple  ,						snake_case__						:     str     ):
							lowerCAmelCase__        =   self.preprocess_text(snake_case__     )
							lowerCAmelCase__        =   self.sp_model.encode(snake_case__  ,						out_type=snake_case__     )
							lowerCAmelCase__        =   []
							for piece in pieces:
									if len(snake_case__     ) > 1 and piece[-1] == str(""","""     ) and piece[-2].isdigit():
											lowerCAmelCase__        =   self.sp_model.EncodeAsPieces(piece[:-1].replace(snake_case__  ,						""""""     )     )
											if piece[0] != SPIECE_UNDERLINE and cur_pieces[0][0] == SPIECE_UNDERLINE:
													if len(cur_pieces[0]     ) == 1:
															lowerCAmelCase__        =   cur_pieces[1:]
													else:
															lowerCAmelCase__        =   cur_pieces[0][1:]
											cur_pieces.append(piece[-1]     )
											new_pieces.extend(snake_case__     )
									else:
											new_pieces.append(snake_case__     )

							return new_pieces




					def 						_SCREAMING_SNAKE_CASE						(	self						:     List[str]  ,						snake_case__						:     Union[str, Any]     ):
							return self.sp_model.PieceToId(snake_case__     )




					def 						_SCREAMING_SNAKE_CASE						(	self						:     Any  ,						snake_case__						:     str     ):
							return self.sp_model.IdToPiece(snake_case__     )




					def 						_SCREAMING_SNAKE_CASE						(	self						:     List[str]  ,						snake_case__						:     Tuple     ):
							lowerCAmelCase__        =   []
							lowerCAmelCase__        =   """"""
							lowerCAmelCase__        =   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(snake_case__     ) + token
											lowerCAmelCase__        =   True
											lowerCAmelCase__        =   []
									else:
											current_sub_tokens.append(snake_case__     )
											lowerCAmelCase__        =   False
							out_string += self.sp_model.decode(snake_case__     )
							return out_string.strip()




					def 						_SCREAMING_SNAKE_CASE						(	self						:     Tuple  ,						snake_case__						:     List[int]  ,						snake_case__						:     Optional[List[int]] = None     ):
							lowerCAmelCase__        =   [self.sep_token_id]
							lowerCAmelCase__        =   [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 						_SCREAMING_SNAKE_CASE						(	self						:     Dict  ,						snake_case__						:     List[int]  ,						snake_case__						:     Optional[List[int]] = None  ,						snake_case__						:     bool = False     ):

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

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




					def 						_SCREAMING_SNAKE_CASE						(	self						:     Optional[int]  ,						snake_case__						:     List[int]  ,						snake_case__						:     Optional[List[int]] = None     ):
							lowerCAmelCase__        =   [self.sep_token_id]
							lowerCAmelCase__        =   [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 						_SCREAMING_SNAKE_CASE						(	self						:     Union[str, Any]  ,						snake_case__						:     str  ,						snake_case__						:     Optional[str] = None     ):
							if not os.path.isdir(snake_case__     ):
									logger.error(F"""Vocabulary path ({save_directory}) should be a directory"""     )
									return
							lowerCAmelCase__        =   os.path.join(
							    snake_case__  ,						(filename_prefix + """-""" if filename_prefix else """""") + VOCAB_FILES_NAMES["""vocab_file"""]     )

							if os.path.abspath(self.vocab_file     ) != os.path.abspath(snake_case__     ) and os.path.isfile(self.vocab_file     ):
									copyfile(self.vocab_file  ,						snake_case__     )
							elif not os.path.isfile(self.vocab_file     ):
									with open(snake_case__  ,						"""wb"""     ) as fi:
											lowerCAmelCase__        =   self.sp_model.serialized_model_proto()
											fi.write(snake_case__     )

							return (out_vocab_file,)





"""simple docstring"""




def 							_UpperCAmelCase		(       lowerCamelCase__ = 50     ):





		"""simple docstring"""




		lowerCAmelCase__        =   [[0] * 3 for _ in range(length + 1     )]

		for row_length in range(length + 1     ):
				for tile_length in range(2			,  5     ):
						for tile_start in range(row_length - tile_length + 1     ):
								different_colour_ways_number[row_length][tile_length - 2] += (
								    different_colour_ways_number[row_length - tile_start - tile_length][
								        tile_length - 2
								    ]
								    + 1
								)

		return sum(different_colour_ways_number[length]     )


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




