

"""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    (       __UpperCamelCase				,     __UpperCamelCase   ):
 '''simple docstring'''





 warnings.warn(__UpperCamelCase				,     __UpperCamelCase   )
 requires_backends(__UpperCamelCase				,     """sklearn"""   )
 return (preds == labels).mean()
def 	lowerCAmelCase    (       __UpperCamelCase				,     __UpperCamelCase   ):
 '''simple docstring'''





 warnings.warn(__UpperCamelCase				,     __UpperCamelCase   )
 requires_backends(__UpperCamelCase				,     """sklearn"""   )
 UpperCAmelCase__       :	Optional[Any]        =       simple_accuracy(__UpperCamelCase				,     __UpperCamelCase   )
 UpperCAmelCase__       :	Union[str, Any]        =       fa_score(y_true=__UpperCamelCase				,     y_pred=__UpperCamelCase   )
 return {
     "acc": acc,
     "f1": fa,
     "acc_and_f1": (acc + fa) / 2,
 }
def 	lowerCAmelCase    (       __UpperCamelCase				,     __UpperCamelCase   ):
 '''simple docstring'''





 warnings.warn(__UpperCamelCase				,     __UpperCamelCase   )
 requires_backends(__UpperCamelCase				,     """sklearn"""   )
 UpperCAmelCase__       :	Optional[int]        =       pearsonr(__UpperCamelCase				,     __UpperCamelCase   )[0]
 UpperCAmelCase__       :	Union[str, Any]        =       spearmanr(__UpperCamelCase				,     __UpperCamelCase   )[0]
 return {
     "pearson": pearson_corr,
     "spearmanr": spearman_corr,
     "corr": (pearson_corr + spearman_corr) / 2,
 }
def 	lowerCAmelCase    (       __UpperCamelCase				,     __UpperCamelCase				,     __UpperCamelCase   ):
 '''simple docstring'''





 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 	lowerCAmelCase    (       __UpperCamelCase				,     __UpperCamelCase				,     __UpperCamelCase   ):
 '''simple docstring'''





 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'''
import os
import sys

_SCREAMING_SNAKE_CASE			=						os.path.join(os.path.dirname(__file__), "src")
sys.path.append(SRC_DIR)


from transformers import (
    AutoConfig,
    AutoModel,
    AutoModelForCausalLM,
    AutoModelForMaskedLM,
    AutoModelForQuestionAnswering,
    AutoModelForSequenceClassification,
    AutoTokenizer,
    add_start_docstrings,
)


_SCREAMING_SNAKE_CASE			=						[
    "torch",
    "numpy",
    "tokenizers",
    "filelock",
    "requests",
    "tqdm",
    "regex",
    "sentencepiece",
    "sacremoses",
    "importlib_metadata",
    "huggingface_hub",
]





@add_start_docstrings(AutoConfig.__doc__     )
def 			lowerCamelCase(							*SCREAMING_SNAKE_CASE_       ,**SCREAMING_SNAKE_CASE_     )		->		int:
			return AutoConfig.from_pretrained(*SCREAMING_SNAKE_CASE_       ,**SCREAMING_SNAKE_CASE_     )





@add_start_docstrings(AutoTokenizer.__doc__     )
def 			lowerCamelCase(							*SCREAMING_SNAKE_CASE_       ,**SCREAMING_SNAKE_CASE_     )		->		List[str]:
			return AutoTokenizer.from_pretrained(*SCREAMING_SNAKE_CASE_       ,**SCREAMING_SNAKE_CASE_     )





@add_start_docstrings(AutoModel.__doc__     )
def 			lowerCamelCase(							*SCREAMING_SNAKE_CASE_       ,**SCREAMING_SNAKE_CASE_     )		->		Union[str, Any]:
			return AutoModel.from_pretrained(*SCREAMING_SNAKE_CASE_       ,**SCREAMING_SNAKE_CASE_     )





@add_start_docstrings(AutoModelForCausalLM.__doc__     )
def 			lowerCamelCase(							*SCREAMING_SNAKE_CASE_       ,**SCREAMING_SNAKE_CASE_     )		->		Optional[int]:
			return AutoModelForCausalLM.from_pretrained(*SCREAMING_SNAKE_CASE_       ,**SCREAMING_SNAKE_CASE_     )





@add_start_docstrings(AutoModelForMaskedLM.__doc__     )
def 			lowerCamelCase(							*SCREAMING_SNAKE_CASE_       ,**SCREAMING_SNAKE_CASE_     )		->		Dict:
			return AutoModelForMaskedLM.from_pretrained(*SCREAMING_SNAKE_CASE_       ,**SCREAMING_SNAKE_CASE_     )





@add_start_docstrings(AutoModelForSequenceClassification.__doc__     )
def 			lowerCamelCase(							*SCREAMING_SNAKE_CASE_       ,**SCREAMING_SNAKE_CASE_     )		->		Union[str, Any]:
			return AutoModelForSequenceClassification.from_pretrained(*SCREAMING_SNAKE_CASE_       ,**SCREAMING_SNAKE_CASE_     )






@add_start_docstrings(AutoModelForQuestionAnswering.__doc__     )
def 			lowerCamelCase(							*SCREAMING_SNAKE_CASE_       ,**SCREAMING_SNAKE_CASE_     )		->		str:
			return AutoModelForQuestionAnswering.from_pretrained(*SCREAMING_SNAKE_CASE_       ,**SCREAMING_SNAKE_CASE_     )




