
"""simple docstring"""





import json
from typing import List, Optional, Tuple

from tokenizers import normalizers
from tokenizers.pre_tokenizers import BertPreTokenizer, PreTokenizer

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_roformer import RoFormerTokenizer
from .tokenization_utils import JiebaPreTokenizer


_a														=		logging.get_logger(__name__)

_a														=		{"""vocab_file""": """vocab.txt""", """tokenizer_file""": """tokenizer.json"""}

_a														=		{
    """vocab_file""": {
        """junnyu/roformer_chinese_small""": """https://huggingface.co/junnyu/roformer_chinese_small/resolve/main/vocab.txt""",
        """junnyu/roformer_chinese_base""": """https://huggingface.co/junnyu/roformer_chinese_base/resolve/main/vocab.txt""",
        """junnyu/roformer_chinese_char_small""": (
            """https://huggingface.co/junnyu/roformer_chinese_char_small/resolve/main/vocab.txt"""
        ),
        """junnyu/roformer_chinese_char_base""": (
            """https://huggingface.co/junnyu/roformer_chinese_char_base/resolve/main/vocab.txt"""
        ),
        """junnyu/roformer_small_discriminator""": (
            """https://huggingface.co/junnyu/roformer_small_discriminator/resolve/main/vocab.txt"""
        ),
        """junnyu/roformer_small_generator""": (
            """https://huggingface.co/junnyu/roformer_small_generator/resolve/main/vocab.txt"""
        ),
    }
}

_a														=		{
    """junnyu/roformer_chinese_small""": 1536,
    """junnyu/roformer_chinese_base""": 1536,
    """junnyu/roformer_chinese_char_small""": 512,
    """junnyu/roformer_chinese_char_base""": 512,
    """junnyu/roformer_small_discriminator""": 128,
    """junnyu/roformer_small_generator""": 128,
}


_a														=		{
    """junnyu/roformer_chinese_small""": {"""do_lower_case""": True},
    """junnyu/roformer_chinese_base""": {"""do_lower_case""": True},
    """junnyu/roformer_chinese_char_small""": {"""do_lower_case""": True},
    """junnyu/roformer_chinese_char_base""": {"""do_lower_case""": True},
    """junnyu/roformer_small_discriminator""": {"""do_lower_case""": True},
    """junnyu/roformer_small_generator""": {"""do_lower_case""": True},
}






class     _UpperCAmelCase(    lowerCamelCase	):
		lowercase__						=      VOCAB_FILES_NAMES
		lowercase__						=      PRETRAINED_VOCAB_FILES_MAP
		lowercase__						=      PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
		lowercase__						=      PRETRAINED_INIT_CONFIGURATION
		lowercase__						=      RoFormerTokenizer



		def __init__(					self				,		__a=None				,		__a=None				,		__a=True				,		__a="[UNK]"				,		__a="[SEP]"				,		__a="[PAD]"				,		__a="[CLS]"				,		__a="[MASK]"				,		__a=True				,		__a=None				,		**__a				,		)       ->       Tuple:






							'''simple docstring'''
							super().__init__(
							    __a				,		tokenizer_file=__a				,		do_lower_case=__a				,		unk_token=__a				,		sep_token=__a				,		pad_token=__a				,		cls_token=__a				,		mask_token=__a				,		tokenize_chinese_chars=__a				,		strip_accents=__a				,		**__a				,		)

							_UpperCamelCase							 =  json.loads(self.backend_tokenizer.normalizer.__getstate__())
							if (
							    pre_tok_state.get('''lowercase'''				,		__a) != do_lower_case
							    or pre_tok_state.get('''strip_accents'''				,		__a) != strip_accents
							):
												_UpperCamelCase							 =  getattr(__a				,		pre_tok_state.pop('''type'''))
												_UpperCamelCase							 =  do_lower_case
												_UpperCamelCase							 =  strip_accents
												_UpperCamelCase							 =  pre_tok_class(**__a)

							_UpperCamelCase							 =  do_lower_case



		def __getstate__(					self)       ->       Optional[Any]:






							'''simple docstring'''
							_UpperCamelCase							 =  self.__dict__.copy()
							_UpperCamelCase							 =  BertPreTokenizer()
							return state



		def __setstate__(					self				,		__a)       ->       List[Any]:






							'''simple docstring'''
							_UpperCamelCase							 =  d
							_UpperCamelCase							 =  self.__dict__['''_tokenizer'''].get_vocab()
							_UpperCamelCase							 =  PreTokenizer.custom(JiebaPreTokenizer(__a))



		def 						UpperCAmelCase							(					self				,		__a				,		__a=None)       ->       Optional[int]:






							'''simple docstring'''
							_UpperCamelCase							 =  [self.cls_token_id] + token_ids_a + [self.sep_token_id]

							if token_ids_a:
												output += token_ids_a + [self.sep_token_id]

							return output



		def 						UpperCAmelCase							(					self				,		__a				,		__a = None)       ->       List[int]:






							'''simple docstring'''
							_UpperCamelCase							 =  [self.sep_token_id]
							_UpperCamelCase							 =  [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 						UpperCAmelCase							(					self				,		__a				,		__a = None)       ->       Tuple[str]:






							'''simple docstring'''
							_UpperCamelCase							 =  self._tokenizer.model.save(__a				,		name=__a)
							return tuple(__a)




		def 						UpperCAmelCase							(					self				,		__a				,		__a=None				,		__a=None				,		__a=False				,		**__a				,		)       ->       int:






							'''simple docstring'''
							_UpperCamelCase							 =  BertPreTokenizer()
							return super().save_pretrained(__a				,		__a				,		__a				,		__a				,		**__a)








"""simple docstring"""





from collections import defaultdict






class     _UpperCAmelCase:



		def __init__(					self				,		__a				,		__a)       ->       Union[str, Any]:






							'''simple docstring'''
							_UpperCamelCase							 =  total  # total no of tasks (N)

							# DP table will have a dimension of (2^M)*N
							# initially all values are set to -1
							_UpperCamelCase							 =  [
							    [-1 for i in range(total + 1)] for j in range(2 ** len(__a))
							]

							_UpperCamelCase							 =  defaultdict(__a)  # stores the list of persons for each task

							# final_mask is used to check if all persons are included by setting all bits
							# to 1
							_UpperCamelCase							 =  (1 << len(__a)) - 1



		def 						UpperCAmelCase							(					self				,		__a				,		__a)       ->       Dict:






							'''simple docstring'''
							# if mask == self.finalmask all persons are distributed tasks, return 1
							if mask == self.final_mask:
												return 1

							# if not everyone gets the task and no more tasks are available, return 0
							if task_no > self.total_tasks:
												return 0

							# if case already considered
							if self.dp[mask][task_no] != -1:
												return self.dp[mask][task_no]

							# Number of ways when we don't this task in the arrangement
							_UpperCamelCase							 =  self.count_ways_until(__a				,		task_no + 1)

							# now assign the tasks one by one to all possible persons and recursively
							# assign for the remaining tasks.
							if task_no in self.task:
												for p in self.task[task_no]:
																	# if p is already given a task
																	if mask & (1 << p):
																						continue

																	# assign this task to p and change the mask value. And recursively
																	# assign tasks with the new mask value.
																	total_ways_util += self.count_ways_until(mask | (1 << p)				,		task_no + 1)

        # save the value.
							_UpperCamelCase							 =  total_ways_util

							return self.dp[mask][task_no]




		def 						UpperCAmelCase							(					self				,		__a)       ->       int:






							'''simple docstring'''
							# Store the list of persons for each task
							for i in range(len(__a)):
												for j in task_performed[i]:
																	self.task[j].append(__a)

        # call the function to fill the DP table, final answer is stored in dp[0][1]
							return self.count_ways_until(0				,		1)


if __name__ == "__main__":
				_a														=		5  # total no of tasks (the value of N)

				# the list of tasks that can be done by M persons.
				_a														=		[[1, 3, 4], [1, 2, 5], [3, 4]]
				print(
				    AssignmentUsingBitmask(task_performed, total_tasks).count_no_of_ways(
				        task_performed
				    )
				)






