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


_lowercase          =						logging.get_logger(__name__)
_lowercase          =						{"""vocab_file""": """spiece.model"""}

_lowercase          =						{
    """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""",
    }
}

_lowercase          =						{
    """albert-base-v1""": 512,
    """albert-large-v1""": 512,
    """albert-xlarge-v1""": 512,
    """albert-xxlarge-v1""": 512,
    """albert-base-v2""": 512,
    """albert-large-v2""": 512,
    """albert-xlarge-v2""": 512,
    """albert-xxlarge-v2""": 512,
}

_lowercase          =						"""▁"""




class     UpperCAmelCase_	(						_SCREAMING_SNAKE_CASE					):






						'''simple docstring'''






						_lowercase						: Any										=  VOCAB_FILES_NAMES
						_lowercase						: int										=  PRETRAINED_VOCAB_FILES_MAP
						_lowercase						: Union[str, Any]										=  PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES




						def __init__(   self       ,  _lowercase       ,  _lowercase=True       ,  _lowercase=True       ,  _lowercase=False       ,  _lowercase="[CLS]"       ,  _lowercase="[SEP]"       ,  _lowercase="<unk>"       ,  _lowercase="[SEP]"       ,  _lowercase="<pad>"       ,  _lowercase="[CLS]"       ,  _lowercase="[MASK]"       ,  _lowercase = None       ,  **_lowercase       ,  ):

												"""simple docstring"""



												_lowerCAmelCase    		=					(
												    AddedToken(_lowercase       ,  lstrip=_lowercase       ,  rstrip=_lowercase       ,  normalized=_lowercase )
												    if isinstance(_lowercase       ,  _lowercase )
												    else mask_token
												)

												_lowerCAmelCase    		=					{} if sp_model_kwargs is None else sp_model_kwargs

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

												_lowerCAmelCase    		=					do_lower_case
												_lowerCAmelCase    		=					remove_space
												_lowerCAmelCase    		=					keep_accents
												_lowerCAmelCase    		=					vocab_file

												_lowerCAmelCase    		=					spm.SentencePieceProcessor(**self.sp_model_kwargs )
												self.sp_model.Load(_lowercase )




						@property
						def    _lowercase      (   self ):

												"""simple docstring"""



												return len(self.sp_model )




						def    _lowercase      (   self ):

												"""simple docstring"""



												_lowerCAmelCase    		=					{self.convert_ids_to_tokens(_lowercase ): i for i in range(self.vocab_size )}
												vocab.update(self.added_tokens_encoder )
												return vocab




						def __getstate__(   self ):

												"""simple docstring"""



												_lowerCAmelCase    		=					self.__dict__.copy()
												_lowerCAmelCase    		=					None
												return state




						def __setstate__(   self       ,  _lowercase ):

												"""simple docstring"""



												_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    _lowercase      (   self       ,  _lowercase ):

												"""simple docstring"""



												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"""       ,  _lowercase )
																		_lowerCAmelCase    		=					"""""".join([c for c in outputs if not unicodedata.combining(_lowercase )] )
												if self.do_lower_case:
																		_lowerCAmelCase    		=					outputs.lower()

												return outputs




						def    _lowercase      (   self       ,  _lowercase ):

												"""simple docstring"""



												_lowerCAmelCase    		=					self.preprocess_text(_lowercase )
												_lowerCAmelCase    		=					self.sp_model.encode(_lowercase       ,  out_type=_lowercase )
												_lowerCAmelCase    		=					[]
												for piece in pieces:
																		if len(_lowercase ) > 1 and piece[-1] == str(""",""" ) and piece[-2].isdigit():
																								_lowerCAmelCase    		=					self.sp_model.EncodeAsPieces(piece[:-1].replace(_lowercase       ,  """""" ) )
																								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(_lowercase )
																		else:
																								new_pieces.append(_lowercase )

												return new_pieces




						def    _lowercase      (   self       ,  _lowercase ):

												"""simple docstring"""



												return self.sp_model.PieceToId(_lowercase )




						def    _lowercase      (   self       ,  _lowercase ):

												"""simple docstring"""



												return self.sp_model.IdToPiece(_lowercase )




						def    _lowercase      (   self       ,  _lowercase ):

												"""simple docstring"""



												_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(_lowercase ) + token
																								_lowerCAmelCase    		=					True
																								_lowerCAmelCase    		=					[]
																		else:
																								current_sub_tokens.append(_lowercase )
																								_lowerCAmelCase    		=					False
												out_string += self.sp_model.decode(_lowercase )
												return out_string.strip()




						def    _lowercase      (   self       ,  _lowercase       ,  _lowercase = None ):

												"""simple docstring"""



												_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    _lowercase      (   self       ,  _lowercase       ,  _lowercase = None       ,  _lowercase = False ):

												"""simple docstring"""



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

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




						def    _lowercase      (   self       ,  _lowercase       ,  _lowercase = None ):

												"""simple docstring"""



												_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    _lowercase      (   self       ,  _lowercase       ,  _lowercase = None ):

												"""simple docstring"""



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

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

												return (out_vocab_file,)


'''simple docstring'''



from itertools import product


def A (__lowerCamelCase :int					,      __lowerCamelCase :int						):
						_lowerCAmelCase    		=					sides_number
						_lowerCAmelCase    		=					max_face_number * dice_number
						_lowerCAmelCase    		=					[0] * (max_total + 1)

						_lowerCAmelCase    		=					1
						_lowerCAmelCase    		=					range(__lowerCamelCase					,      max_face_number + 1						)
						for dice_numbers in product(__lowerCamelCase					,      repeat=__lowerCamelCase						):
												_lowerCAmelCase    		=					sum(__lowerCamelCase						)
												totals_frequencies[total] += 1

						return totals_frequencies


def A ():
						_lowerCAmelCase    		=					total_frequency_distribution(
						    sides_number=4					,      dice_number=9						)
						_lowerCAmelCase    		=					total_frequency_distribution(
						    sides_number=6					,      dice_number=6						)

						_lowerCAmelCase    		=					0
						_lowerCAmelCase    		=					9
						_lowerCAmelCase    		=					4 * 9
						_lowerCAmelCase    		=					6
						for peter_total in range(__lowerCamelCase					,      max_peter_total + 1						):
												peter_wins_count += peter_totals_frequencies[peter_total] * sum(
												    colin_totals_frequencies[min_colin_total:peter_total]						)

						_lowerCAmelCase    		=					(4**9) * (6**6)
						_lowerCAmelCase    		=					peter_wins_count / total_games_number

						_lowerCAmelCase    		=					round(__lowerCamelCase					,      ndigits=7						)

						return rounded_peter_win_probability


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