

'''simple docstring'''


import os
from shutil import copyfile
from typing import List, Optional, Tuple

from ...tokenization_utils import AddedToken
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import is_sentencepiece_available, logging


if is_sentencepiece_available():
					from .tokenization_fnet import FNetTokenizer
else:
					lowerCAmelCase__						:       Optional[int]										=						None

lowerCAmelCase__						:       List[Any]										=						logging.get_logger(__name__)
lowerCAmelCase__						:       Dict										=						{"""vocab_file""": """spiece.model""", """tokenizer_file""": """tokenizer.json"""}

lowerCAmelCase__						:       Union[str, Any]										=						{
    """vocab_file""": {
        """google/fnet-base""": """https://huggingface.co/google/fnet-base/resolve/main/spiece.model""",
        """google/fnet-large""": """https://huggingface.co/google/fnet-large/resolve/main/spiece.model""",
    },
    """tokenizer_file""": {
        """google/fnet-base""": """https://huggingface.co/google/fnet-base/resolve/main/tokenizer.json""",
        """google/fnet-large""": """https://huggingface.co/google/fnet-large/resolve/main/tokenizer.json""",
    },
}

lowerCAmelCase__						:       str										=						{
    """google/fnet-base""": 512,
    """google/fnet-large""": 512,
}

lowerCAmelCase__						:       Any										=						"""▁"""




class     a			(				SCREAMING_SNAKE_CASE       ):






						"""simple docstring"""




						__UpperCAmelCase			     =    VOCAB_FILES_NAMES
						__UpperCAmelCase			     =    PRETRAINED_VOCAB_FILES_MAP
						__UpperCAmelCase			     =    PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
						__UpperCAmelCase			     =    ["""input_ids""", """token_type_ids"""]
						__UpperCAmelCase			     =    FNetTokenizer







						def __init__(							self					:      str			,			snake_case_					:      Optional[int]=None			,			snake_case_					:      Any=None			,			snake_case_					:      str=False			,			snake_case_					:      Tuple=True			,			snake_case_					:      Dict=True			,			snake_case_					:      str="<unk>"			,			snake_case_					:      Dict="[SEP]"			,			snake_case_					:      Union[str, Any]="<pad>"			,			snake_case_					:      str="[CLS]"			,			snake_case_					:      List[str]="[MASK]"			,			**snake_case_					:      Dict			,			):



								'''simple docstring'''



								snake_case__						:       Any       						=  (
								    AddedToken(snake_case_			,			lstrip=snake_case_			,			rstrip=snake_case_			,			normalized=snake_case_  )
								    if isinstance(snake_case_			,			snake_case_  )
								    else mask_token
								)

								super().__init__(
								    snake_case_			,			tokenizer_file=snake_case_			,			do_lower_case=snake_case_			,			remove_space=snake_case_			,			keep_accents=snake_case_			,			unk_token=snake_case_			,			sep_token=snake_case_			,			pad_token=snake_case_			,			cls_token=snake_case_			,			mask_token=snake_case_			,			**snake_case_			,			)

								snake_case__						:       Dict       						=  do_lower_case
								snake_case__						:       Tuple       						=  remove_space
								snake_case__						:       Tuple       						=  keep_accents
								snake_case__						:       Optional[Any]       						=  vocab_file
								snake_case__						:       Tuple       						=  False if not self.vocab_file else True







						def       __magic_name__							(							self					:      Optional[int]			,			snake_case_					:      List[int]			,			snake_case_					:      Optional[List[int]] = None  ):



								'''simple docstring'''



								snake_case__						:       str       						=  [self.sep_token_id]
								snake_case__						:       Optional[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       __magic_name__							(							self					:      Tuple			,			snake_case_					:      List[int]			,			snake_case_					:      Optional[List[int]] = None  ):



								'''simple docstring'''



								snake_case__						:       Dict       						=  [self.sep_token_id]
								snake_case__						:       Tuple       						=  [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       __magic_name__							(							self					:      List[str]			,			snake_case_					:      str			,			snake_case_					:      Optional[str] = None  ):



								'''simple docstring'''



								if not os.path.isdir(snake_case_  ):
										logger.error(F"""Vocabulary path ({save_directory}) should be a directory"""  )
										return
								snake_case__						:       Union[str, Any]       						=  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_  ):
										copyfile(self.vocab_file			,			snake_case_  )

								return (out_vocab_file,)






'''simple docstring'''


def 	_a       (				__lowerCAmelCase		:      float   ,							__lowerCAmelCase		:      float   ,							__lowerCAmelCase		:      int     ):

		"""simple docstring"""

		if principal <= 0:
				raise Exception('''Principal borrowed must be > 0'''     )
		if rate_per_annum < 0:
				raise Exception('''Rate of interest must be >= 0'''     )
		if years_to_repay <= 0 or not isinstance(__lowerCAmelCase   ,							__lowerCAmelCase     ):
				raise Exception('''Years to repay must be an integer > 0'''     )

		# Yearly rate is divided by 12 to get monthly rate
		snake_case__						:       int       						=  rate_per_annum / 12

		# Years to repay is multiplied by 12 to get number of payments as payment is monthly
		snake_case__						:       Tuple       						=  years_to_repay * 12

		return (
		    principal
		    * rate_per_month
		    * (1 + rate_per_month) ** number_of_payments
		    / ((1 + rate_per_month) ** number_of_payments - 1)
		)


if __name__ == "__main__":
					import doctest

					doctest.testmod()



