
"""simple docstring"""




from arguments import TokenizerTrainingArguments
from datasets import load_dataset
from tqdm import tqdm

from transformers import AutoTokenizer, HfArgumentParser
from transformers.models.gpta.tokenization_gpta import bytes_to_unicode

def __snake_case (      UpperCamelCase=10    )       ->    Optional[int]:


		"""simple docstring"""





		for _ in tqdm(range(0						,					args.n_examples						,					UpperCamelCase    )    ):
				yield [next(UpperCamelCase    )[args.text_column] for _ in range(UpperCamelCase    )]


# Configuration
__lowerCAmelCase							:  int 				=		HfArgumentParser(TokenizerTrainingArguments)
__lowerCAmelCase							:  Optional[int] 				=		parser.parse_args()

# Base tokenizer
__lowerCAmelCase							:  int 				=		AutoTokenizer.from_pretrained(args.base_tokenizer)
__lowerCAmelCase							:  Optional[Any] 				=		list(bytes_to_unicode().values())

# Load dataset
__lowerCAmelCase							:  Any 				=		load_dataset(args.dataset_name, split='''train''', streaming=True)
__lowerCAmelCase							:  Optional[Any] 				=		iter(dataset)


# Training and saving
__lowerCAmelCase							:  str 				=		tokenizer.train_new_from_iterator(
    batch_iterator(), vocab_size=args.vocab_size, initial_alphabet=base_vocab
)




new_tokenizer.save_pretrained(args.tokenizer_name, push_to_hub=args.push_to_hub)






"""simple docstring"""




__lowerCAmelCase							:  Any 				=		{
    '''0''': 1,
    '''1''': 1,
    '''2''': 2,
    '''3''': 6,
    '''4''': 24,
    '''5''': 120,
    '''6''': 720,
    '''7''': 5040,
    '''8''': 40320,
    '''9''': 362880,
}

__lowerCAmelCase							:  List[Any] 				=		{145: 145}

__lowerCAmelCase							:  Any 				=		{
    145: 0,
    169: 3,
    36301: 3,
    1454: 3,
    871: 2,
    45361: 2,
    872: 2,
}

def __snake_case (      UpperCamelCase    )       ->    int:


		"""simple docstring"""





		if n in CACHE_SUM_DIGIT_FACTORIALS:
				return CACHE_SUM_DIGIT_FACTORIALS[n]
		a__   		=     sum(DIGIT_FACTORIALS[let] for let in str(UpperCamelCase    )    )
		a__   		=     ret
		return ret

def __snake_case (      UpperCamelCase						,					UpperCamelCase = None    )       ->    int:


		"""simple docstring"""





		a__   		=     previous or set()
		if n in CHAIN_LENGTH_CACHE:
				return CHAIN_LENGTH_CACHE[n]
		a__   		=     sum_digit_factorials(UpperCamelCase    )
		if next_number in previous:
				a__   		=     0
				return 0
		else:
				previous.add(UpperCamelCase    )
				a__   		=     1 + chain_length(UpperCamelCase						,					UpperCamelCase    )
				a__   		=     ret
				return ret

def __snake_case (      UpperCamelCase = 60						,					UpperCamelCase = 1_000_000    )       ->    int:


		"""simple docstring"""





		return sum(1 for i in range(1						,					UpperCamelCase    ) if chain_length(UpperCamelCase    ) == num_terms    )


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




