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


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 					lowerCamelCase   (     _snake_case    ,_snake_case ):
    warnings.warn(_snake_case    ,_snake_case )
    requires_backends(_snake_case    ,'sklearn' )
    return (preds == labels).mean()
def 					lowerCamelCase   (     _snake_case    ,_snake_case ):
    warnings.warn(_snake_case    ,_snake_case )
    requires_backends(_snake_case    ,'sklearn' )
    UpperCAmelCase__	:      List[str]     							=					simple_accuracy(_snake_case    ,_snake_case )
    UpperCAmelCase__	:      str     							=					fa_score(y_true=_snake_case    ,y_pred=_snake_case )
    return {
        "acc": acc,
        "f1": fa,
        "acc_and_f1": (acc + fa) / 2,
    }
def 					lowerCamelCase   (     _snake_case    ,_snake_case ):
    warnings.warn(_snake_case    ,_snake_case )
    requires_backends(_snake_case    ,'sklearn' )
    UpperCAmelCase__	:      Optional[int]     							=					pearsonr(_snake_case    ,_snake_case )[0]
    UpperCAmelCase__	:      str     							=					spearmanr(_snake_case    ,_snake_case )[0]
    return {
        "pearson": pearson_corr,
        "spearmanr": spearman_corr,
        "corr": (pearson_corr + spearman_corr) / 2,
    }
def 					lowerCamelCase   (     _snake_case    ,_snake_case    ,_snake_case ):
    warnings.warn(_snake_case    ,_snake_case )
    requires_backends(_snake_case    ,'sklearn' )
    assert len(_snake_case ) == len(_snake_case ), F'''Predictions and labels have mismatched lengths {len(_snake_case )} and {len(_snake_case )}'''
    if task_name == "cola":
        return {"mcc": matthews_corrcoef(_snake_case    ,_snake_case )}
    elif task_name == "sst-2":
        return {"acc": simple_accuracy(_snake_case    ,_snake_case )}
    elif task_name == "mrpc":
        return acc_and_fa(_snake_case    ,_snake_case )
    elif task_name == "sts-b":
        return pearson_and_spearman(_snake_case    ,_snake_case )
    elif task_name == "qqp":
        return acc_and_fa(_snake_case    ,_snake_case )
    elif task_name == "mnli":
        return {"mnli/acc": simple_accuracy(_snake_case    ,_snake_case )}
    elif task_name == "mnli-mm":
        return {"mnli-mm/acc": simple_accuracy(_snake_case    ,_snake_case )}
    elif task_name == "qnli":
        return {"acc": simple_accuracy(_snake_case    ,_snake_case )}
    elif task_name == "rte":
        return {"acc": simple_accuracy(_snake_case    ,_snake_case )}
    elif task_name == "wnli":
        return {"acc": simple_accuracy(_snake_case    ,_snake_case )}
    elif task_name == "hans":
        return {"acc": simple_accuracy(_snake_case    ,_snake_case )}
    else:
        raise KeyError(_snake_case )

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



"""simple docstring"""



def 					lowerCamelCase   (     _snake_case    ,_snake_case ):
    return int((input_a, input_a).count(0 ) == 0 )
def 					lowerCamelCase   (     ):
    assert and_gate(0    ,0 ) == 0
    assert and_gate(0    ,1 ) == 0
    assert and_gate(1    ,0 ) == 0
    assert and_gate(1    ,1 ) == 1


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

