





import logging
import os
import random
import sys
from dataclasses import dataclass, field
from typing import Optional

import datasets
import numpy as np
import pandas as pd
from datasets import load_dataset

import transformers
from transformers import (
    AutoConfig,
    BartForSequenceClassification,
    DataCollatorWithPadding,
    EvalPrediction,
    HfArgumentParser,
    TapexTokenizer,
    Trainer,
    TrainingArguments,
    default_data_collator,
    set_seed,
)
from transformers.trainer_utils import get_last_checkpoint
from transformers.utils import check_min_version
from transformers.utils.versions import require_version


# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
check_min_version("4.17.0.dev0")

require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/text-classification/requirements.txt")

_a						=   logging.getLogger(__name__)






@dataclass
class       __A					:

			'''simple docstring'''







			lowerCAmelCase_							  =		field(
			    default="""tab_fact"""    ,       metadata={"""help""": """The name of the dataset to use (via the datasets library)."""}				)
			lowerCAmelCase_							  =		field(
			    default="""tab_fact"""    ,       metadata={"""help""": """The configuration name of the dataset to use (via the datasets library)."""}    ,       )
			lowerCAmelCase_							  =		field(
			    default=1024    ,       metadata={
			        """help""": (
			            """The maximum total input sequence length after tokenization. Sequences longer """
			            """than this will be truncated, sequences shorter will be padded."""
			        )
			    }    ,       )
			lowerCAmelCase_							  =		field(
			    default=lowerCAmelCase    ,       metadata={"""help""": """Overwrite the cached preprocessed datasets or not."""}				)
			lowerCAmelCase_							  =		field(
			    default=lowerCAmelCase    ,       metadata={
			        """help""": (
			            """Whether to pad all samples to `max_seq_length`. """
			            """If False, will pad the samples dynamically when batching to the maximum length in the batch."""
			        )
			    }    ,       )
			lowerCAmelCase_							  =		field(
			    default=lowerCAmelCase    ,       metadata={
			        """help""": (
			            """For debugging purposes or quicker training, truncate the number of training examples to this """
			            """value if set."""
			        )
			    }    ,       )
			lowerCAmelCase_							  =		field(
			    default=lowerCAmelCase    ,       metadata={
			        """help""": (
			            """For debugging purposes or quicker training, truncate the number of evaluation examples to this """
			            """value if set."""
			        )
			    }    ,       )
			lowerCAmelCase_							  =		field(
			    default=lowerCAmelCase    ,       metadata={
			        """help""": (
			            """For debugging purposes or quicker training, truncate the number of prediction examples to this """
			            """value if set."""
			        )
			    }    ,       )
			lowerCAmelCase_							  =		field(
			    default=lowerCAmelCase    ,       metadata={"""help""": """A csv or a json file containing the training data."""}				)
			lowerCAmelCase_							  =		field(
			    default=lowerCAmelCase    ,       metadata={"""help""": """A csv or a json file containing the validation data."""}				)
			lowerCAmelCase_							  =		field(default=lowerCAmelCase    ,       metadata={"""help""": """A csv or a json file containing the test data."""}				)





			def 	__lowerCamelCase       (					self							):



				'''simple docstring'''







				if self.dataset_name is not None:
					pass
				elif self.train_file is None or self.validation_file is None:
					raise ValueError('''Need either a GLUE task, a training/validation file or a dataset name.'''							)
				else:
					lowerCamelCase__              =	self.train_file.split('''.'''							)[-1]
					assert train_extension in ["csv", "json"], "`train_file` should be a csv or a json file."
					lowerCamelCase__              =	self.validation_file.split('''.'''							)[-1]
					assert (
					    validation_extension == train_extension
					), "`validation_file` should have the same extension (csv or json) as `train_file`."






@dataclass
class       __A					:

			'''simple docstring'''







			lowerCAmelCase_							  =		field(
			    default=lowerCAmelCase    ,       metadata={"""help""": """Path to pretrained model or model identifier from huggingface.co/models"""}				)
			lowerCAmelCase_							  =		field(
			    default=lowerCAmelCase    ,       metadata={"""help""": """Pretrained config name or path if not the same as model_name"""}				)
			lowerCAmelCase_							  =		field(
			    default=lowerCAmelCase    ,       metadata={"""help""": """Pretrained tokenizer name or path if not the same as model_name"""}				)
			lowerCAmelCase_							  =		field(
			    default=lowerCAmelCase    ,       metadata={"""help""": """Where do you want to store the pretrained models downloaded from huggingface.co"""}    ,       )
			lowerCAmelCase_							  =		field(
			    default=lowerCAmelCase    ,       metadata={"""help""": """Whether to use one of the fast tokenizer (backed by the tokenizers library) or not."""}    ,       )
			lowerCAmelCase_							  =		field(
			    default="""main"""    ,       metadata={"""help""": """The specific model version to use (can be a branch name, tag name or commit id)."""}    ,       )
			lowerCAmelCase_							  =		field(
			    default=lowerCAmelCase    ,       metadata={
			        """help""": (
			            """Will use the token generated when running `huggingface-cli login` (necessary to use this script """
			            """with private models)."""
			        )
			    }    ,       )





def lowerCAmelCase__()       ->   int:







	'''simple docstring'''







	lowerCamelCase__              =	HfArgumentParser((ModelArguments, DataTrainingArguments, TrainingArguments)							)
	if len(sys.argv							) == 2 and sys.argv[1].endswith('''.json'''							):
		# If we pass only one argument to the script and it's the path to a json file,
		# let's parse it to get our arguments.
		lowerCamelCase__       ,			lowerCamelCase__       ,			lowerCamelCase__              =	parser.parse_json_file(json_file=os.path.abspath(sys.argv[1]							)							)
	else:
		lowerCamelCase__       ,			lowerCamelCase__       ,			lowerCamelCase__              =	parser.parse_args_into_dataclasses()

	# Setup logging
	logging.basicConfig(
	    format='''%(asctime)s - %(levelname)s - %(name)s - %(message)s''' ,datefmt='''%m/%d/%Y %H:%M:%S''' ,handlers=[logging.StreamHandler(sys.stdout							)] ,)

	lowerCamelCase__              =	training_args.get_process_log_level()
	logger.setLevel(__snake_case							)
	datasets.utils.logging.set_verbosity(__snake_case							)
	transformers.utils.logging.set_verbosity(__snake_case							)
	transformers.utils.logging.enable_default_handler()
	transformers.utils.logging.enable_explicit_format()

	# Log on each process the small summary:
	logger.warning(
	    F'Process rank: {training_args.local_rank}, device: {training_args.device}, n_gpu: {training_args.n_gpu}'
	    + F'distributed training: {bool(training_args.local_rank != -1							)}, 16-bits training: {training_args.fpaa}'							)
	logger.info(F'Training/evaluation parameters {training_args}'							)

	# Detecting last checkpoint.
	lowerCamelCase__              =	None
	if os.path.isdir(training_args.output_dir							) and training_args.do_train and not training_args.overwrite_output_dir:
		lowerCamelCase__              =	get_last_checkpoint(training_args.output_dir							)
		if last_checkpoint is None and len(os.listdir(training_args.output_dir							)							) > 0:
			raise ValueError(
			    F'Output directory ({training_args.output_dir}) already exists and is not empty. '
			    '''Use --overwrite_output_dir to overcome.'''							)
		elif last_checkpoint is not None and training_args.resume_from_checkpoint is None:
			logger.info(
			    F'Checkpoint detected, resuming training at {last_checkpoint}. To avoid this behavior, change '
			    '''the `--output_dir` or add `--overwrite_output_dir` to train from scratch.'''							)

    # Set seed before initializing model.
	set_seed(training_args.seed							)

	# Get the datasets: you can either provide your own CSV/JSON training and evaluation files (see below)
	# or specify a GLUE benchmark task (the dataset will be downloaded automatically from the datasets Hub).
	#
	# For JSON files, this script will use the `question` column for the input question and `table` column for the corresponding table.
	#
	# If the CSVs/JSONs contain only one non-label column, the script does single sentence classification on this
	# single column. You can easily tweak this behavior (see below)
	#
	# In distributed training, the load_dataset function guarantee that only one local process can concurrently
	# download the dataset.
	if data_args.dataset_name is not None:
		# Downloading and loading a dataset from the hub.
		lowerCamelCase__              =	load_dataset(
		    data_args.dataset_name ,data_args.dataset_config_name ,cache_dir=model_args.cache_dir							)
	else:
		# Loading a dataset from your local files.
		# CSV/JSON training and evaluation files are needed.
		lowerCamelCase__              =	{'''train''': data_args.train_file, '''validation''': data_args.validation_file}

		# Get the test dataset: you can provide your own CSV/JSON test file (see below)
		# when you use `do_predict` without specifying a GLUE benchmark task.
		if training_args.do_predict:
			if data_args.test_file is not None:
				lowerCamelCase__              =	data_args.train_file.split('''.'''							)[-1]
				lowerCamelCase__              =	data_args.test_file.split('''.'''							)[-1]
				assert (
				    test_extension == train_extension
				), "`test_file` should have the same extension (csv or json) as `train_file`."
				lowerCamelCase__              =	data_args.test_file
			else:
				raise ValueError('''Need either a GLUE task or a test file for `do_predict`.'''							)

		for key in data_files.keys():
			logger.info(F'load a local file for {key}: {data_files[key]}'							)

		if data_args.train_file.endswith('''.csv'''							):
			# Loading a dataset from local csv files
			lowerCamelCase__              =	load_dataset('''csv''' ,data_files=__snake_case ,cache_dir=model_args.cache_dir							)
		else:
			# Loading a dataset from local json files
			lowerCamelCase__              =	load_dataset('''json''' ,data_files=__snake_case ,cache_dir=model_args.cache_dir							)
    # See more about loading any type of standard or custom dataset at
    # https://huggingface.co/docs/datasets/loading_datasets.html.

    # Labels
	lowerCamelCase__              =	raw_datasets['''train'''].features['''label'''].names
	lowerCamelCase__              =	len(__snake_case							)

	# Load pretrained model and tokenizer
	#
	# In distributed training, the .from_pretrained methods guarantee that only one local process can concurrently
	# download model & vocab.
	lowerCamelCase__              =	AutoConfig.from_pretrained(
	    model_args.config_name if model_args.config_name else model_args.model_name_or_path ,num_labels=__snake_case ,cache_dir=model_args.cache_dir ,revision=model_args.model_revision ,use_auth_token=True if model_args.use_auth_token else None ,)
	# load tapex tokenizer
	lowerCamelCase__              =	TapexTokenizer.from_pretrained(
	    model_args.tokenizer_name if model_args.tokenizer_name else model_args.model_name_or_path ,cache_dir=model_args.cache_dir ,use_fast=model_args.use_fast_tokenizer ,revision=model_args.model_revision ,use_auth_token=True if model_args.use_auth_token else None ,add_prefix_space=__snake_case ,)
	lowerCamelCase__              =	BartForSequenceClassification.from_pretrained(
	    model_args.model_name_or_path ,from_tf=bool('''.ckpt''' in model_args.model_name_or_path							) ,config=__snake_case ,cache_dir=model_args.cache_dir ,revision=model_args.model_revision ,use_auth_token=True if model_args.use_auth_token else None ,)

	# Padding strategy
	if data_args.pad_to_max_length:
		lowerCamelCase__              =	'''max_length'''
	else:
		# We will pad later, dynamically at batch creation, to the max sequence length in each batch
		lowerCamelCase__              =	False

	# Some models have set the order of the labels to use, so let's make sure we do use it.
	lowerCamelCase__              =	{'''Refused''': 0, '''Entailed''': 1}
	lowerCamelCase__              =	{0: '''Refused''', 1: '''Entailed'''}

	if data_args.max_seq_length > tokenizer.model_max_length:
		logger.warning(
		    F'The max_seq_length passed ({data_args.max_seq_length}) is larger than the maximum length for the'
		    F'model ({tokenizer.model_max_length}). Using max_seq_length={tokenizer.model_max_length}.'							)
	lowerCamelCase__              =	min(data_args.max_seq_length ,tokenizer.model_max_length							)

	def preprocess_tabfact_function(__snake_case							):
		# Tokenize the texts
		def _convert_table_text_to_pandas(__snake_case							):
			lowerCamelCase__              =	[_table_row.split('''#'''							) for _table_row in _table_text.strip('''\n'''							).split('''\n'''							)]
			lowerCamelCase__              =	pd.DataFrame.from_records(_table_content[1:] ,columns=_table_content[0]							)
			return _table_pd

		lowerCamelCase__              =	examples['''statement''']
		lowerCamelCase__              =	list(map(_convert_table_text_to_pandas ,examples['''table_text''']							)							)
		lowerCamelCase__              =	tokenizer(__snake_case ,__snake_case ,padding=__snake_case ,max_length=__snake_case ,truncation=__snake_case							)

		lowerCamelCase__              =	examples['''label''']
		return result

	with training_args.main_process_first(desc='''dataset map pre-processing'''							):
		lowerCamelCase__              =	raw_datasets.map(
		    __snake_case ,batched=__snake_case ,load_from_cache_file=not data_args.overwrite_cache ,desc='''Running tokenizer on dataset''' ,)
	if training_args.do_train:
		if "train" not in raw_datasets:
			raise ValueError('''--do_train requires a train dataset'''							)
		lowerCamelCase__              =	raw_datasets['''train''']
		if data_args.max_train_samples is not None:
			lowerCamelCase__              =	train_dataset.select(range(data_args.max_train_samples							)							)

	if training_args.do_eval:
		if "validation" not in raw_datasets and "validation_matched" not in raw_datasets:
			raise ValueError('''--do_eval requires a validation dataset'''							)
		lowerCamelCase__              =	raw_datasets['''validation''']
		if data_args.max_eval_samples is not None:
			lowerCamelCase__              =	eval_dataset.select(range(data_args.max_eval_samples							)							)

	if training_args.do_predict or data_args.test_file is not None:
		if "test" not in raw_datasets and "test_matched" not in raw_datasets:
			raise ValueError('''--do_predict requires a test dataset'''							)
		lowerCamelCase__              =	raw_datasets['''test''']
		if data_args.max_predict_samples is not None:
			lowerCamelCase__              =	predict_dataset.select(range(data_args.max_predict_samples							)							)

    # Log a few random samples from the training set:
	if training_args.do_train:
		for index in random.sample(range(len(__snake_case							)							) ,3							):
			logger.info(F'Sample {index} of the training set: {train_dataset[index]}.'							)

    # You can define your custom compute_metrics function. It takes an `EvalPrediction` object (a namedtuple with a
    # predictions and label_ids field) and has to return a dictionary string to float.
	def compute_metrics(__snake_case							):
		lowerCamelCase__              =	p.predictions[0] if isinstance(p.predictions ,__snake_case							) else p.predictions
		lowerCamelCase__              =	np.argmax(__snake_case ,axis=1							)
		return {"accuracy": (preds == p.label_ids).astype(np.floataa							).mean().item()}

	# Data collator will default to DataCollatorWithPadding, so we change it if we already did the padding.
	if data_args.pad_to_max_length:
		lowerCamelCase__              =	default_data_collator
	elif training_args.fpaa:
		lowerCamelCase__              =	DataCollatorWithPadding(__snake_case ,pad_to_multiple_of=8							)
	else:
		lowerCamelCase__              =	None

	# Initialize our Trainer
	lowerCamelCase__              =	Trainer(
	    model=__snake_case ,args=__snake_case ,train_dataset=train_dataset if training_args.do_train else None ,eval_dataset=eval_dataset if training_args.do_eval else None ,compute_metrics=__snake_case ,tokenizer=__snake_case ,data_collator=__snake_case ,)

	# Training
	if training_args.do_train:
		lowerCamelCase__              =	None
		if training_args.resume_from_checkpoint is not None:
			lowerCamelCase__              =	training_args.resume_from_checkpoint
		elif last_checkpoint is not None:
			lowerCamelCase__              =	last_checkpoint
		lowerCamelCase__              =	trainer.train(resume_from_checkpoint=__snake_case							)
		lowerCamelCase__              =	train_result.metrics
		lowerCamelCase__              =	(
		    data_args.max_train_samples if data_args.max_train_samples is not None else len(__snake_case							)
		)
		lowerCamelCase__              =	min(__snake_case ,len(__snake_case							)							)

		trainer.save_model()  # Saves the tokenizer too for easy upload

		trainer.log_metrics('''train''' ,__snake_case							)
		trainer.save_metrics('''train''' ,__snake_case							)
		trainer.save_state()

	# Evaluation
	if training_args.do_eval:
		logger.info('''*** Evaluate ***'''							)

		lowerCamelCase__              =	trainer.evaluate(eval_dataset=__snake_case							)
		lowerCamelCase__              =	data_args.max_eval_samples if data_args.max_eval_samples is not None else len(__snake_case							)
		lowerCamelCase__              =	min(__snake_case ,len(__snake_case							)							)

		trainer.log_metrics('''eval''' ,__snake_case							)
		trainer.save_metrics('''eval''' ,__snake_case							)

	if training_args.do_predict:
		logger.info('''*** Predict ***'''							)

		# Removing the `label` columns because it contains -1 and Trainer won't like that.
		lowerCamelCase__              =	predict_dataset.remove_columns('''label'''							)
		lowerCamelCase__              =	trainer.predict(__snake_case ,metric_key_prefix='''predict'''							).predictions
		lowerCamelCase__              =	np.argmax(__snake_case ,axis=1							)

		lowerCamelCase__              =	os.path.join(training_args.output_dir ,'''predict_results_tabfact.txt'''							)
		if trainer.is_world_process_zero():
			with open(__snake_case ,'''w'''							) as writer:
				logger.info('''***** Predict Results *****'''							)
				writer.write('''index\tprediction\n'''							)
				for index, item in enumerate(__snake_case							):
					lowerCamelCase__              =	label_list[item]
					writer.write(F'{index}\t{item}\n'							)

	lowerCamelCase__              =	{'''finetuned_from''': model_args.model_name_or_path, '''tasks''': '''text-classification'''}

	if training_args.push_to_hub:
		trainer.push_to_hub(**__snake_case							)
	else:
		trainer.create_model_card(**__snake_case							)





def lowerCAmelCase__(__snake_case							)       ->   Union[str, Any]:







	'''simple docstring'''







	main()


if __name__ == "__main__":
			main()










from math import sqrt





def lowerCAmelCase__(__snake_case							)       ->   bool:







	'''simple docstring'''







	assert isinstance(__snake_case ,__snake_case							) and (
	    number >= 0
	), "'number' must been an int and positive"

	lowerCamelCase__              =	True

	# 0 and 1 are none primes.
	if number <= 1:
		lowerCamelCase__              =	False

	for divisor in range(2 ,int(round(sqrt(__snake_case							)							)							) + 1							):
		# if 'number' divisible by 'divisor' then sets 'status'
		# of false and break up the loop.
		if number % divisor == 0:
			lowerCamelCase__              =	False
			break

    # precondition
	assert isinstance(__snake_case ,__snake_case							), "'status' must been from type bool"

	return status





def lowerCAmelCase__(__snake_case							)       ->   Any:







	'''simple docstring'''







	assert isinstance(__snake_case ,__snake_case							) and (n > 2), "'N' must been an int and > 2"

	# beginList: contains all natural numbers from 2 up to N
	lowerCamelCase__              =	list(range(2 ,n + 1							)							)

	lowerCamelCase__              =	[]  # this list will be returns.

	# actual sieve of erathostenes
	for i in range(len(__snake_case							)							):
		for j in range(i + 1 ,len(__snake_case							)							):
			if (begin_list[i] != 0) and (begin_list[j] % begin_list[i] == 0):
				lowerCamelCase__              =	0

    # filters actual prime numbers.
	lowerCamelCase__              =	[x for x in begin_list if x != 0]

	# precondition
	assert isinstance(__snake_case ,__snake_case							), "'ans' must been from type list"

	return ans





def lowerCAmelCase__(__snake_case							)       ->   Optional[Any]:







	'''simple docstring'''







	assert isinstance(__snake_case ,__snake_case							) and (n > 2), "'N' must been an int and > 2"

	lowerCamelCase__              =	[]

	# iterates over all numbers between 2 up to N+1
	# if a number is prime then appends to list 'ans'
	for number in range(2 ,n + 1							):
		if is_prime(__snake_case							):
			ans.append(__snake_case							)

    # precondition
	assert isinstance(__snake_case ,__snake_case							), "'ans' must been from type list"

	return ans





def lowerCAmelCase__(__snake_case							)       ->   List[str]:







	'''simple docstring'''







	assert isinstance(__snake_case ,__snake_case							) and number >= 0, "'number' must been an int and >= 0"

	lowerCamelCase__              =	[]  # this list will be returns of the function.

	# potential prime number factors.

	lowerCamelCase__              =	2

	lowerCamelCase__              =	number

	if number == 0 or number == 1:
		ans.append(__snake_case							)

	# if 'number' not prime then builds the prime factorization of 'number'
	elif not is_prime(__snake_case							):
		while quotient != 1:
			if is_prime(__snake_case							) and (quotient % factor == 0):
				ans.append(__snake_case							)
				quotient /= factor
			else:
				factor += 1

	else:
		ans.append(__snake_case							)

	# precondition
	assert isinstance(__snake_case ,__snake_case							), "'ans' must been from type list"

	return ans





def lowerCAmelCase__(__snake_case							)       ->   List[Any]:







	'''simple docstring'''







	assert isinstance(__snake_case ,__snake_case							) and (
	    number >= 0
	), "'number' bust been an int and >= 0"

	lowerCamelCase__              =	0

	# prime factorization of 'number'
	lowerCamelCase__              =	prime_factorization(__snake_case							)

	lowerCamelCase__              =	max(__snake_case							)

	# precondition
	assert isinstance(__snake_case ,__snake_case							), "'ans' must been from type int"

	return ans





def lowerCAmelCase__(__snake_case							)       ->   Dict:







	'''simple docstring'''







	assert isinstance(__snake_case ,__snake_case							) and (
	    number >= 0
	), "'number' bust been an int and >= 0"

	lowerCamelCase__              =	0

	# prime factorization of 'number'
	lowerCamelCase__              =	prime_factorization(__snake_case							)

	lowerCamelCase__              =	min(__snake_case							)

	# precondition
	assert isinstance(__snake_case ,__snake_case							), "'ans' must been from type int"

	return ans





def lowerCAmelCase__(__snake_case							)       ->   List[Any]:







	'''simple docstring'''







	assert isinstance(__snake_case ,__snake_case							), "'number' must been an int"
	assert isinstance(number % 2 == 0 ,__snake_case							), "compare bust been from type bool"

	return number % 2 == 0





def lowerCAmelCase__(__snake_case							)       ->   List[str]:







	'''simple docstring'''







	assert isinstance(__snake_case ,__snake_case							), "'number' must been an int"
	assert isinstance(number % 2 != 0 ,__snake_case							), "compare bust been from type bool"

	return number % 2 != 0





def lowerCAmelCase__(__snake_case							)       ->   List[Any]:







	'''simple docstring'''







	assert (
	    isinstance(__snake_case ,__snake_case							) and (number > 2) and is_even(__snake_case							)
	), "'number' must been an int, even and > 2"

	lowerCamelCase__              =	[]  # this list will returned

	# creates a list of prime numbers between 2 up to 'number'
	lowerCamelCase__              =	get_prime_numbers(__snake_case							)
	lowerCamelCase__              =	len(__snake_case							)

	# run variable for while-loops.
	lowerCamelCase__              =	0
	lowerCamelCase__              =	None

	# exit variable. for break up the loops
	lowerCamelCase__              =	True

	while i < len_pn and loop:
		lowerCamelCase__              =	i + 1

		while j < len_pn and loop:
			if prime_numbers[i] + prime_numbers[j] == number:
				lowerCamelCase__              =	False
				ans.append(prime_numbers[i]							)
				ans.append(prime_numbers[j]							)

			j += 1

		i += 1

	# precondition
	assert (
	    isinstance(__snake_case ,__snake_case							)
	    and (len(__snake_case							) == 2)
	    and (ans[0] + ans[1] == number)
	    and is_prime(ans[0]							)
	    and is_prime(ans[1]							)
	), "'ans' must contains two primes. And sum of elements must been eq 'number'"

	return ans





def lowerCAmelCase__(__snake_case ,__snake_case							)       ->   str:







	'''simple docstring'''







	assert (
	    isinstance(__snake_case ,__snake_case							)
	    and isinstance(__snake_case ,__snake_case							)
	    and (numbera >= 0)
	    and (numbera >= 0)
	), "'number1' and 'number2' must been positive integer."

	lowerCamelCase__              =	0

	while numbera != 0:
		lowerCamelCase__              =	numbera % numbera
		lowerCamelCase__              =	numbera
		lowerCamelCase__              =	rest

	# precondition
	assert isinstance(__snake_case ,__snake_case							) and (
	    numbera >= 0
	), "'number' must been from type int and positive"

	return numbera





def lowerCAmelCase__(__snake_case ,__snake_case							)       ->   Any:







	'''simple docstring'''







	assert (
	    isinstance(__snake_case ,__snake_case							)
	    and isinstance(__snake_case ,__snake_case							)
	    and (numbera >= 1)
	    and (numbera >= 1)
	), "'number1' and 'number2' must been positive integer."

	lowerCamelCase__              =	1  # actual answer that will be return.

	# for kgV (x,1)
	if numbera > 1 and numbera > 1:
		# builds the prime factorization of 'number1' and 'number2'
		lowerCamelCase__              =	prime_factorization(__snake_case							)
		lowerCamelCase__              =	prime_factorization(__snake_case							)

	elif numbera == 1 or numbera == 1:
		lowerCamelCase__              =	[]
		lowerCamelCase__              =	[]
		lowerCamelCase__              =	max(__snake_case ,__snake_case							)

	lowerCamelCase__              =	0
	lowerCamelCase__              =	0

	lowerCamelCase__              =	[]  # captured numbers int both 'primeFac1' and 'primeFac2'

	# iterates through primeFac1
	for n in prime_fac_a:
		if n not in done:
			if n in prime_fac_a:
				lowerCamelCase__              =	prime_fac_a.count(__snake_case							)
				lowerCamelCase__              =	prime_fac_a.count(__snake_case							)

				for _ in range(max(__snake_case ,__snake_case							)							):
					ans *= n

			else:
				lowerCamelCase__              =	prime_fac_a.count(__snake_case							)

				for _ in range(__snake_case							):
					ans *= n

			done.append(__snake_case							)

    # iterates through primeFac2
	for n in prime_fac_a:
		if n not in done:
			lowerCamelCase__              =	prime_fac_a.count(__snake_case							)

			for _ in range(__snake_case							):
				ans *= n

			done.append(__snake_case							)

    # precondition
	assert isinstance(__snake_case ,__snake_case							) and (
	    ans >= 0
	), "'ans' must been from type int and positive"

	return ans





def lowerCAmelCase__(__snake_case							)       ->   Union[str, Any]:







	'''simple docstring'''







	assert isinstance(__snake_case ,__snake_case							) and (n >= 0), "'number' must been a positive int"

	lowerCamelCase__              =	0
	lowerCamelCase__              =	2  # this variable holds the answer

	while index < n:
		index += 1

		ans += 1  # counts to the next number

		# if ans not prime then
		# runs to the next prime number.
		while not is_prime(__snake_case							):
			ans += 1

    # precondition
	assert isinstance(__snake_case ,__snake_case							) and is_prime(
	    __snake_case							), "'ans' must been a prime number and from type int"

	return ans





def lowerCAmelCase__(__snake_case ,__snake_case							)       ->   Dict:







	'''simple docstring'''







	assert (
	    is_prime(__snake_case							) and is_prime(__snake_case							) and (p_number_a < p_number_a)
	), "The arguments must been prime numbers and 'pNumber1' < 'pNumber2'"

	lowerCamelCase__              =	p_number_a + 1  # jump to the next number

	lowerCamelCase__              =	[]  # this list will be returns.

	# if number is not prime then
	# fetch the next prime number.
	while not is_prime(__snake_case							):
		number += 1

	while number < p_number_a:
		ans.append(__snake_case							)

		number += 1

		# fetch the next prime number.
		while not is_prime(__snake_case							):
			number += 1

    # precondition
	assert (
	    isinstance(__snake_case ,__snake_case							)
	    and ans[0] != p_number_a
	    and ans[len(__snake_case							) - 1] != p_number_a
	), "'ans' must been a list without the arguments"

	# 'ans' contains not 'pNumber1' and 'pNumber2' !
	return ans





def lowerCAmelCase__(__snake_case							)       ->   Tuple:







	'''simple docstring'''







	assert isinstance(__snake_case ,__snake_case							) and (n >= 1), "'n' must been int and >= 1"

	lowerCamelCase__              =	[]  # will be returned.

	for divisor in range(1 ,n + 1							):
		if n % divisor == 0:
			ans.append(__snake_case							)

    # precondition
	assert ans[0] == 1 and ans[len(__snake_case							) - 1] == n, "Error in function getDivisiors(...)"

	return ans





def lowerCAmelCase__(__snake_case							)       ->   Optional[Any]:







	'''simple docstring'''







	assert isinstance(__snake_case ,__snake_case							) and (
	    number > 1
	), "'number' must been an int and >= 1"

	lowerCamelCase__              =	get_divisors(__snake_case							)

	# precondition
	assert (
	    isinstance(__snake_case ,__snake_case							)
	    and (divisors[0] == 1)
	    and (divisors[len(__snake_case							) - 1] == number)
	), "Error in help-function getDivisiors(...)"

	# summed all divisors up to 'number' (exclusive), hence [:-1]
	return sum(divisors[:-1]							) == number





def lowerCAmelCase__(__snake_case ,__snake_case							)       ->   Tuple:







	'''simple docstring'''







	assert (
	    isinstance(__snake_case ,__snake_case							)
	    and isinstance(__snake_case ,__snake_case							)
	    and (denominator != 0)
	), "The arguments must been from type int and 'denominator' != 0"

	# build the greatest common divisor of numerator and denominator.
	lowerCamelCase__              =	gcd(abs(__snake_case							) ,abs(__snake_case							)							)

	# precondition
	assert (
	    isinstance(__snake_case ,__snake_case							)
	    and (numerator % gcd_of_fraction == 0)
	    and (denominator % gcd_of_fraction == 0)
	), "Error in function gcd(...,...)"

	return (numerator // gcd_of_fraction, denominator // gcd_of_fraction)





def lowerCAmelCase__(__snake_case							)       ->   Optional[int]:







	'''simple docstring'''







	assert isinstance(__snake_case ,__snake_case							) and (n >= 0), "'n' must been a int and >= 0"

	lowerCamelCase__              =	1  # this will be return.

	for factor in range(1 ,n + 1							):
		ans *= factor

	return ans





def lowerCAmelCase__(__snake_case							)       ->   Optional[Any]:







	'''simple docstring'''







	assert isinstance(__snake_case ,__snake_case							) and (n >= 0), "'n' must been an int and >= 0"

	lowerCamelCase__              =	0
	lowerCamelCase__              =	1
	lowerCamelCase__              =	1  # this will be return

	for _ in range(n - 1							):
		lowerCamelCase__              =	ans
		ans += fiba
		lowerCamelCase__              =	tmp

	return ans



