




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


SCREAMING_SNAKE_CASE__				:				Union[str, Any]       							=		(
    '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	:  str			,						UpperCamelCase	:  Any				):





							'''simple docstring'''


							warnings.warn(lowercase__			,						lowercase__				)
							requires_backends(lowercase__			,						'''sklearn'''				)
							return (preds == labels).mean()
def 		snake_case_   (UpperCamelCase	:  Optional[Any]			,						UpperCamelCase	:  Tuple				):





							'''simple docstring'''


							warnings.warn(lowercase__			,						lowercase__				)
							requires_backends(lowercase__			,						'''sklearn'''				)
							_a     					=    simple_accuracy(lowercase__			,						lowercase__				)
							_a     					=    fa_score(y_true=lowercase__			,						y_pred=lowercase__				)
							return {
							    "acc": acc,
							    "f1": fa,
							    "acc_and_f1": (acc + fa) / 2,
							}
def 		snake_case_   (UpperCamelCase	:  Optional[Any]			,						UpperCamelCase	:  Tuple				):





							'''simple docstring'''


							warnings.warn(lowercase__			,						lowercase__				)
							requires_backends(lowercase__			,						'''sklearn'''				)
							_a     					=    pearsonr(lowercase__			,						lowercase__				)[0]
							_a     					=    spearmanr(lowercase__			,						lowercase__				)[0]
							return {
							    "pearson": pearson_corr,
							    "spearmanr": spearman_corr,
							    "corr": (pearson_corr + spearman_corr) / 2,
							}
def 		snake_case_   (UpperCamelCase	:  Dict			,						UpperCamelCase	:  str			,						UpperCamelCase	:  List[str]				):





							'''simple docstring'''


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

def 		snake_case_   (UpperCamelCase	:  Tuple			,						UpperCamelCase	:  List[Any]			,						UpperCamelCase	:  List[str]				):





							'''simple docstring'''


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







'''simple docstring'''


from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_sentencepiece_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


_snake_case				:				List[str]       							=		{'configuration_xlnet': ['XLNET_PRETRAINED_CONFIG_ARCHIVE_MAP', 'XLNetConfig']}

try:
				if not is_sentencepiece_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				_snake_case				:				List[Any]       							=		['XLNetTokenizer']

try:
				if not is_tokenizers_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				_snake_case				:				int       							=		['XLNetTokenizerFast']

try:
				if not is_torch_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				_snake_case				:				Optional[int]       							=		[
				    'XLNET_PRETRAINED_MODEL_ARCHIVE_LIST',
				    'XLNetForMultipleChoice',
				    'XLNetForQuestionAnswering',
				    'XLNetForQuestionAnsweringSimple',
				    'XLNetForSequenceClassification',
				    'XLNetForTokenClassification',
				    'XLNetLMHeadModel',
				    'XLNetModel',
				    'XLNetPreTrainedModel',
				    'load_tf_weights_in_xlnet',
				]

try:
				if not is_tf_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				_snake_case				:				str       							=		[
				    'TF_XLNET_PRETRAINED_MODEL_ARCHIVE_LIST',
				    'TFXLNetForMultipleChoice',
				    'TFXLNetForQuestionAnsweringSimple',
				    'TFXLNetForSequenceClassification',
				    'TFXLNetForTokenClassification',
				    'TFXLNetLMHeadModel',
				    'TFXLNetMainLayer',
				    'TFXLNetModel',
				    'TFXLNetPreTrainedModel',
				]


if TYPE_CHECKING:
				from .configuration_xlnet import XLNET_PRETRAINED_CONFIG_ARCHIVE_MAP, XLNetConfig

				try:
								if not is_sentencepiece_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .tokenization_xlnet import XLNetTokenizer

				try:
								if not is_tokenizers_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .tokenization_xlnet_fast import XLNetTokenizerFast

				try:
								if not is_torch_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_xlnet import (
								    XLNET_PRETRAINED_MODEL_ARCHIVE_LIST,
								    XLNetForMultipleChoice,
								    XLNetForQuestionAnswering,
								    XLNetForQuestionAnsweringSimple,
								    XLNetForSequenceClassification,
								    XLNetForTokenClassification,
								    XLNetLMHeadModel,
								    XLNetModel,
								    XLNetPreTrainedModel,
								    load_tf_weights_in_xlnet,
								)

				try:
								if not is_tf_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_tf_xlnet import (
								    TF_XLNET_PRETRAINED_MODEL_ARCHIVE_LIST,
								    TFXLNetForMultipleChoice,
								    TFXLNetForQuestionAnsweringSimple,
								    TFXLNetForSequenceClassification,
								    TFXLNetForTokenClassification,
								    TFXLNetLMHeadModel,
								    TFXLNetMainLayer,
								    TFXLNetModel,
								    TFXLNetPreTrainedModel,
								)

else:
				import sys

				_snake_case				:				Union[str, Any]       							=		_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)

