

"""simple docstring"""






import json
from typing import Iterator, List, Union

from tokenizers import AddedToken, Regex, Tokenizer, decoders, normalizers, pre_tokenizers, trainers
from tokenizers.implementations.base_tokenizer import BaseTokenizer
from tokenizers.models import Unigram
from tokenizers.processors import TemplateProcessing







class       snake_case__  ( lowerCAmelCase_     ):







			def __init__(			self			: Optional[int]			,  lowercase			: str = "▁"			,  lowercase			: bool = True			,  lowercase			: Union[str, AddedToken] = "<unk>"			,  lowercase			: Union[str, AddedToken] = "</s>"			,  lowercase			: Union[str, AddedToken] = "<pad>"			,  ):





								'''simple docstring'''



								UpperCAmelCase			:   Any      =				{
								    "pad": {"id": 0, "token": pad_token},
								    "eos": {"id": 1, "token": eos_token},
								    "unk": {"id": 2, "token": unk_token},
								}

								UpperCAmelCase			:   List[Any]      =				[None] * len(self.special_tokens  )
								for token_dict in self.special_tokens.values():
													UpperCAmelCase			:   List[str]      =				token_dict["token"]

								UpperCAmelCase			:   List[str]      =				Tokenizer(Unigram()  )

								UpperCAmelCase			:   List[Any]      =				normalizers.Sequence(
								    [
								        normalizers.Nmt(),
								        normalizers.NFKC(),
								        normalizers.Replace(Regex(" {2,}"  )			,  " "  ),
								        normalizers.Lowercase(),
								    ]  )
								UpperCAmelCase			:   List[str]      =				pre_tokenizers.Sequence(
								    [
								        pre_tokenizers.Metaspace(replacement=lowercase			,  add_prefix_space=lowercase  ),
								        pre_tokenizers.Digits(individual_digits=lowercase  ),
								        pre_tokenizers.Punctuation(),
								    ]  )
								UpperCAmelCase			:   List[Any]      =				decoders.Metaspace(replacement=lowercase			,  add_prefix_space=lowercase  )

								UpperCAmelCase			:   List[str]      =				TemplateProcessing(
								    single=f"""$A {self.special_tokens['eos']['token']}"""			,  special_tokens=[(self.special_tokens["eos"]["token"], self.special_tokens["eos"]["id"])]			,  )

								UpperCAmelCase			:   str      =				{
								    "model": "SentencePieceUnigram",
								    "replacement": replacement,
								    "add_prefix_space": add_prefix_space,
								}

								super().__init__(lowercase			,  lowercase  )







			def 			__lowerCAmelCase				(			self			: Optional[int]			,  lowercase			: Union[str, List[str]]			,  lowercase			: int = 80_00			,  lowercase			: bool = True			,  ):





								'''simple docstring'''



								UpperCAmelCase			:   int      =				trainers.UnigramTrainer(
								    vocab_size=lowercase			,  special_tokens=self.special_tokens_list			,  show_progress=lowercase			,  )

								if isinstance(lowercase			,  lowercase  ):
													UpperCAmelCase			:   Any      =				[files]
								self._tokenizer.train(lowercase			,  trainer=lowercase  )

								self.add_unk_id()







			def 			__lowerCAmelCase				(			self			: Tuple			,  lowercase			: Union[Iterator[str], Iterator[Iterator[str]]]			,  lowercase			: int = 80_00			,  lowercase			: bool = True			,  ):





								'''simple docstring'''



								UpperCAmelCase			:   Dict      =				trainers.UnigramTrainer(
								    vocab_size=lowercase			,  special_tokens=self.special_tokens_list			,  show_progress=lowercase			,  )

								self._tokenizer.train_from_iterator(lowercase			,  trainer=lowercase  )

								self.add_unk_id()







			def 			__lowerCAmelCase				(			self			: Union[str, Any]  ):





								'''simple docstring'''



								UpperCAmelCase			:   Union[str, Any]      =				json.loads(self._tokenizer.to_str()  )

								UpperCAmelCase			:   Any      =				self.special_tokens["unk"]["id"]

								UpperCAmelCase			:   List[Any]      =				Tokenizer.from_str(json.dumps(lowercase  )  )









"""simple docstring"""






def   lowercase_	(    _lowercase       :		int							,      _lowercase       :		int	):




					'''simple docstring'''






					return int(input_a == input_a == 0	)



def   lowercase_	(    ):




					'''simple docstring'''






					print("Truth Table of NOR Gate:"	)
					print("|   Input 1   |  Input 2  | Output |"	)
					print(F"""|      0      |    0      |  {nor_gate(0							,      0	)}     |"""	)
					print(F"""|      0      |    1      |  {nor_gate(0							,      1	)}     |"""	)
					print(F"""|      1      |    0      |  {nor_gate(1							,      0	)}     |"""	)
					print(F"""|      1      |    1      |  {nor_gate(1							,      1	)}     |"""	)


if __name__ == "__main__":
	import doctest

	doctest.testmod()
	main()


