



"""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    _snake_case		(		UpperCamelCase		:	List[str]    ,	UpperCamelCase		:	str		):
 warnings.warn(UpperCamelCase    ,	UpperCamelCase		)
 requires_backends(UpperCamelCase    ,	"""sklearn"""		)
 return (preds == labels).mean()

def    _snake_case		(		UpperCamelCase		:	List[str]    ,	UpperCamelCase		:	Any		):
 warnings.warn(UpperCamelCase    ,	UpperCamelCase		)
 requires_backends(UpperCamelCase    ,	"""sklearn"""		)
 UpperCAmelCase			:      List[str]			=			simple_accuracy(UpperCamelCase    ,	UpperCamelCase		)
 UpperCAmelCase			:      str			=			fa_score(y_true=UpperCamelCase    ,	y_pred=UpperCamelCase		)
 return {
     "acc": acc,
     "f1": fa,
     "acc_and_f1": (acc + fa) / 2,
 }

def    _snake_case		(		UpperCamelCase		:	Union[str, Any]    ,	UpperCamelCase		:	Dict		):
 warnings.warn(UpperCamelCase    ,	UpperCamelCase		)
 requires_backends(UpperCamelCase    ,	"""sklearn"""		)
 UpperCAmelCase			:      str			=			pearsonr(UpperCamelCase    ,	UpperCamelCase		)[0]
 UpperCAmelCase			:      List[str]			=			spearmanr(UpperCamelCase    ,	UpperCamelCase		)[0]
 return {
     "pearson": pearson_corr,
     "spearmanr": spearman_corr,
     "corr": (pearson_corr + spearman_corr) / 2,
 }

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

def    _snake_case		(		UpperCamelCase		:	str    ,	UpperCamelCase		:	Union[str, Any]    ,	UpperCamelCase		:	Any		):
 warnings.warn(UpperCamelCase    ,	UpperCamelCase		)
 requires_backends(UpperCamelCase    ,	"""sklearn"""		)
 if len(UpperCamelCase		) != len(UpperCamelCase		):
  raise ValueError(F"Predictions and labels have mismatched lengths {len(UpperCamelCase		)} and {len(UpperCamelCase		)}"		)
 if task_name == "xnli":
  return {"acc": simple_accuracy(UpperCamelCase    ,	UpperCamelCase		)}
 else:
  raise KeyError(UpperCamelCase		)





"""simple docstring"""
def    _snake_case		(		UpperCamelCase		:	int    ,	UpperCamelCase		:	int		):
 return 1 if input_a == input_a else 0

def    _snake_case		(		):
 assert xnor_gate(0    ,	0		) == 1
 assert xnor_gate(0    ,	1		) == 0
 assert xnor_gate(1    ,	0		) == 0
 assert xnor_gate(1    ,	1		) == 1


if __name__ == "__main__":
      print(xnor_gate(0, 0))
      print(xnor_gate(0, 1))
      print(xnor_gate(1, 0))
      print(xnor_gate(1, 1))
