'''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 _lowercase	(      lowerCamelCase__							,    lowerCamelCase__						)					->       Tuple:





       """simple docstring"""


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

def _lowercase	(      lowerCamelCase__							,    lowerCamelCase__						)					->       List[str]:





       """simple docstring"""


       warnings.warn(_lowerCamelCase							,    _lowerCamelCase						)
       requires_backends(_lowerCamelCase							,    "sklearn"						)
       __UpperCAmelCase  :				List[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 _lowercase	(      lowerCamelCase__							,    lowerCamelCase__						)					->       str:





       """simple docstring"""


       warnings.warn(_lowerCamelCase							,    _lowerCamelCase						)
       requires_backends(_lowerCamelCase							,    "sklearn"						)
       __UpperCAmelCase  :				Tuple       				=		pearsonr(_lowerCamelCase							,    _lowerCamelCase						)[0]
       __UpperCAmelCase  :				List[str]       				=		spearmanr(_lowerCamelCase							,    _lowerCamelCase						)[0]
       return {
           "pearson": pearson_corr,
           "spearmanr": spearman_corr,
           "corr": (pearson_corr + spearman_corr) / 2,
       }

def _lowercase	(      lowerCamelCase__							,    lowerCamelCase__							,    lowerCamelCase__						)					->       Optional[int]:





       """simple docstring"""


       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 _lowercase	(      lowerCamelCase__							,    lowerCamelCase__							,    lowerCamelCase__						)					->       Tuple:





       """simple docstring"""


       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'''




def _lowercase	(      lowerCamelCase__							,    lowerCamelCase__						)					->       int:





       """simple docstring"""


       return number | (1 << position)

def _lowercase	(      lowerCamelCase__							,    lowerCamelCase__						)					->       int:





       """simple docstring"""


       return number & ~(1 << position)

def _lowercase	(      lowerCamelCase__							,    lowerCamelCase__						)					->       int:





       """simple docstring"""


       return number ^ (1 << position)

def _lowercase	(      lowerCamelCase__							,    lowerCamelCase__						)					->       bool:





       """simple docstring"""


       return ((number >> position) & 1) == 1

def _lowercase	(      lowerCamelCase__							,    lowerCamelCase__						)					->       int:





       """simple docstring"""


       return int((number & (1 << position)) != 0						)


if __name__ == "__main__":
   import doctest

   doctest.testmod()






