



'''simple docstring'''




import warnings

from ...utils import is_sklearn_available, requires_backends


if is_sklearn_available():
							from scipy.stats import pearsonr, spearmanr
							from sklearn.metrics import fa_score, matthews_corrcoef


a     :    List[str]      						=					(
    """This metric will be removed from the library soon, metrics should be handled with the 🤗 Evaluate """
    """library. You can have a look at this example script for pointers: """
    """https://github.com/huggingface/transformers/blob/main/examples/pytorch/text-classification/run_glue.py"""
)



def    __lowerCamelCase						(      _lowercase			,       _lowercase	)   ->    Any:
							warnings.warn(_lowerCamelCase			,       _lowerCamelCase	)
							requires_backends(_lowerCamelCase			,       """sklearn"""	)
							return (preds == labels).mean()



def    __lowerCamelCase						(      _lowercase			,       _lowercase	)   ->    Any:
							warnings.warn(_lowerCamelCase			,       _lowerCamelCase	)
							requires_backends(_lowerCamelCase			,       """sklearn"""	)
							UpperCAmelCase  :	Union[str, Any]							  =	simple_accuracy(_lowerCamelCase			,       _lowerCamelCase	)
							UpperCAmelCase  :	Optional[int]							  =	fa_score(y_true=_lowerCamelCase			,       y_pred=_lowerCamelCase	)
							return {
							    "acc": acc,
							    "f1": fa,
							    "acc_and_f1": (acc + fa) / 2,
							}



def    __lowerCamelCase						(      _lowercase			,       _lowercase	)   ->    Tuple:
							warnings.warn(_lowerCamelCase			,       _lowerCamelCase	)
							requires_backends(_lowerCamelCase			,       """sklearn"""	)
							UpperCAmelCase  :	Any							  =	pearsonr(_lowerCamelCase			,       _lowerCamelCase	)[0]
							UpperCAmelCase  :	Any							  =	spearmanr(_lowerCamelCase			,       _lowerCamelCase	)[0]
							return {
							    "pearson": pearson_corr,
							    "spearmanr": spearman_corr,
							    "corr": (pearson_corr + spearman_corr) / 2,
							}



def    __lowerCamelCase						(      _lowercase			,       _lowercase			,       _lowercase	)   ->    str:
							warnings.warn(_lowerCamelCase			,       _lowerCamelCase	)
							requires_backends(_lowerCamelCase			,       """sklearn"""	)
							assert len(_lowerCamelCase	) == len(_lowerCamelCase	), F'''Predictions and labels have mismatched lengths {len(_lowerCamelCase	)} and {len(_lowerCamelCase	)}'''
							if task_name == "cola":
														return {"mcc": matthews_corrcoef(_lowerCamelCase			,       _lowerCamelCase	)}
							elif task_name == "sst-2":
														return {"acc": simple_accuracy(_lowerCamelCase			,       _lowerCamelCase	)}
							elif task_name == "mrpc":
														return acc_and_fa(_lowerCamelCase			,       _lowerCamelCase	)
							elif task_name == "sts-b":
														return pearson_and_spearman(_lowerCamelCase			,       _lowerCamelCase	)
							elif task_name == "qqp":
														return acc_and_fa(_lowerCamelCase			,       _lowerCamelCase	)
							elif task_name == "mnli":
														return {"mnli/acc": simple_accuracy(_lowerCamelCase			,       _lowerCamelCase	)}
							elif task_name == "mnli-mm":
														return {"mnli-mm/acc": simple_accuracy(_lowerCamelCase			,       _lowerCamelCase	)}
							elif task_name == "qnli":
														return {"acc": simple_accuracy(_lowerCamelCase			,       _lowerCamelCase	)}
							elif task_name == "rte":
														return {"acc": simple_accuracy(_lowerCamelCase			,       _lowerCamelCase	)}
							elif task_name == "wnli":
														return {"acc": simple_accuracy(_lowerCamelCase			,       _lowerCamelCase	)}
							elif task_name == "hans":
														return {"acc": simple_accuracy(_lowerCamelCase			,       _lowerCamelCase	)}
							else:
														raise KeyError(_lowerCamelCase	)



def    __lowerCamelCase						(      _lowercase			,       _lowercase			,       _lowercase	)   ->    Dict:
							warnings.warn(_lowerCamelCase			,       _lowerCamelCase	)
							requires_backends(_lowerCamelCase			,       """sklearn"""	)
							if len(_lowerCamelCase	) != len(_lowerCamelCase	):
														raise ValueError(F'''Predictions and labels have mismatched lengths {len(_lowerCamelCase	)} and {len(_lowerCamelCase	)}'''	)
							if task_name == "xnli":
														return {"acc": simple_accuracy(_lowerCamelCase			,       _lowerCamelCase	)}
							else:
														raise KeyError(_lowerCamelCase	)






'''simple docstring'''




import math



def    __lowerCamelCase						(      _lowercase	)   ->    bool:
							assert isinstance(_lowercase			,       _lowercase	) and (
							    number >= 0
							), "'number' must been an int and positive"

							if 1 < number < 4:
														# 2 and 3 are primes
														return True
							elif number < 2 or not number % 2:
														# Negatives, 0, 1 and all even numbers are not primes
														return False

							UpperCAmelCase  :	str							  =	range(3			,       int(math.sqrt(_lowercase	) + 1	)			,       2	)
							return not any(not number % i for i in odd_numbers	)



def    __lowerCamelCase						(      _lowercase			,       _lowercase=1			,       **_lowercase	)   ->    Union[str, Any]:
							UpperCAmelCase  :	Optional[int]							  =	factor * value
							UpperCAmelCase  :	List[Any]							  =	value

							while not is_prime(_lowercase	):
														value += 1 if not ("desc" in kwargs and kwargs["desc"] is True) else -1

							if value == first_value_val:
														return next_prime(value + 1			,       **_lowercase	)
							return value

