





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


UpperCamelCase__											= (
    "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     _UpperCamelCase     (a__   :Dict   ,			a__   :List[Any]       ):






							"""simple docstring"""





							warnings.warn(a__   ,			a__       )
							requires_backends(a__   ,			"""sklearn"""       )
							return (preds == labels).mean()





def     _UpperCamelCase     (a__   :Tuple   ,			a__   :List[str]       ):






							"""simple docstring"""





							warnings.warn(a__   ,			a__       )
							requires_backends(a__   ,			"""sklearn"""       )
							UpperCamelCase__				     =			simple_accuracy(a__   ,			a__       )
							UpperCamelCase__				     =			fa_score(y_true=a__   ,			y_pred=a__       )
							return {
							    "acc": acc,
							    "f1": fa,
							    "acc_and_f1": (acc + fa) / 2,
							}





def     _UpperCamelCase     (a__   :int   ,			a__   :str       ):






							"""simple docstring"""





							warnings.warn(a__   ,			a__       )
							requires_backends(a__   ,			"""sklearn"""       )
							UpperCamelCase__				     =			pearsonr(a__   ,			a__       )[0]
							UpperCamelCase__				     =			spearmanr(a__   ,			a__       )[0]
							return {
							    "pearson": pearson_corr,
							    "spearmanr": spearman_corr,
							    "corr": (pearson_corr + spearman_corr) / 2,
							}





def     _UpperCamelCase     (a__   :Dict   ,			a__   :int   ,			a__   :Any       ):






							"""simple docstring"""





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





def     _UpperCamelCase     (a__   :Optional[int]   ,			a__   :str   ,			a__   :Optional[int]       ):






							"""simple docstring"""





							warnings.warn(a__   ,			a__       )
							requires_backends(a__   ,			"""sklearn"""       )
							if len(a__       ) != len(a__       ):
														raise ValueError(f"""Predictions and labels have mismatched lengths {len(a__       )} and {len(a__       )}"""       )
							if task_name == "xnli":
														return {"acc": simple_accuracy(a__   ,			a__       )}
							else:
														raise KeyError(a__       )









import inspect
import unittest

class        __SCREAMING_SNAKE_CASE					(     unittest.TestCase       ):






							def 				_lowerCamelCase		(						self  ):
														try:
																					import diffusers  # noqa: F401
														except ImportError:
																					assert False







							def 				_lowerCamelCase		(						self  ):
														import diffusers
														from diffusers.dependency_versions_table import deps

														UpperCamelCase__				     =			inspect.getmembers(__lowerCAmelCase  , inspect.isclass  )

														for cls_name, cls_module in all_classes:
																					if "dummy_" in cls_module.__module__:
																												for backend in cls_module._backends:
																																			if backend == "k_diffusion":
																																										UpperCamelCase__				     =			"""k-diffusion"""
																																			elif backend == "invisible_watermark":
																																										UpperCamelCase__				     =			"""invisible-watermark"""
																																			assert backend in deps, f"""{backend} is not in the deps table!"""




