


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


__lowercase     :						Tuple	=     (
    '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							(_SCREAMING_SNAKE_CASE				:       int						,				_SCREAMING_SNAKE_CASE				:       List[Any]       ):
					warnings.warn(_SCREAMING_SNAKE_CASE						,				_SCREAMING_SNAKE_CASE       )
					requires_backends(_SCREAMING_SNAKE_CASE						,				'sklearn'       )
					return (preds == labels).mean()






def   lowerCamelCase							(_SCREAMING_SNAKE_CASE				:       Optional[int]						,				_SCREAMING_SNAKE_CASE				:       List[str]       ):
					warnings.warn(_SCREAMING_SNAKE_CASE						,				_SCREAMING_SNAKE_CASE       )
					requires_backends(_SCREAMING_SNAKE_CASE						,				'sklearn'       )
					__a      :	Dict    =  simple_accuracy(_SCREAMING_SNAKE_CASE						,				_SCREAMING_SNAKE_CASE       )
					__a      :	Optional[int]    =  fa_score(y_true=_SCREAMING_SNAKE_CASE						,				y_pred=_SCREAMING_SNAKE_CASE       )
					return {
					    "acc": acc,
					    "f1": fa,
					    "acc_and_f1": (acc + fa) / 2,
					}






def   lowerCamelCase							(_SCREAMING_SNAKE_CASE				:       Dict						,				_SCREAMING_SNAKE_CASE				:       Optional[Any]       ):
					warnings.warn(_SCREAMING_SNAKE_CASE						,				_SCREAMING_SNAKE_CASE       )
					requires_backends(_SCREAMING_SNAKE_CASE						,				'sklearn'       )
					__a      :	Tuple    =  pearsonr(_SCREAMING_SNAKE_CASE						,				_SCREAMING_SNAKE_CASE       )[0]
					__a      :	Any    =  spearmanr(_SCREAMING_SNAKE_CASE						,				_SCREAMING_SNAKE_CASE       )[0]
					return {
					    "pearson": pearson_corr,
					    "spearmanr": spearman_corr,
					    "corr": (pearson_corr + spearman_corr) / 2,
					}






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






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







'''simple docstring'''



from typing import TYPE_CHECKING

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


__lowercase     :						Tuple	=     {
    'configuration_distilbert': [
        'DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'DistilBertConfig',
        'DistilBertOnnxConfig',
    ],
    'tokenization_distilbert': ['DistilBertTokenizer'],
}

try:
	if not is_tokenizers_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__lowercase     :						str	=     ['DistilBertTokenizerFast']

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__lowercase     :						Any	=     [
	    'DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST',
	    'DistilBertForMaskedLM',
	    'DistilBertForMultipleChoice',
	    'DistilBertForQuestionAnswering',
	    'DistilBertForSequenceClassification',
	    'DistilBertForTokenClassification',
	    'DistilBertModel',
	    'DistilBertPreTrainedModel',
	]

try:
	if not is_tf_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__lowercase     :						List[str]	=     [
	    'TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST',
	    'TFDistilBertForMaskedLM',
	    'TFDistilBertForMultipleChoice',
	    'TFDistilBertForQuestionAnswering',
	    'TFDistilBertForSequenceClassification',
	    'TFDistilBertForTokenClassification',
	    'TFDistilBertMainLayer',
	    'TFDistilBertModel',
	    'TFDistilBertPreTrainedModel',
	]

try:
	if not is_flax_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__lowercase     :						List[str]	=     [
	    'FlaxDistilBertForMaskedLM',
	    'FlaxDistilBertForMultipleChoice',
	    'FlaxDistilBertForQuestionAnswering',
	    'FlaxDistilBertForSequenceClassification',
	    'FlaxDistilBertForTokenClassification',
	    'FlaxDistilBertModel',
	    'FlaxDistilBertPreTrainedModel',
	]


if TYPE_CHECKING:
	from .configuration_distilbert import (
	    DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
	    DistilBertConfig,
	    DistilBertOnnxConfig,
	)
	from .tokenization_distilbert import DistilBertTokenizer

	try:
		if not is_tokenizers_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .tokenization_distilbert_fast import DistilBertTokenizerFast

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_distilbert import (
		    DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
		    DistilBertForMaskedLM,
		    DistilBertForMultipleChoice,
		    DistilBertForQuestionAnswering,
		    DistilBertForSequenceClassification,
		    DistilBertForTokenClassification,
		    DistilBertModel,
		    DistilBertPreTrainedModel,
		)

	try:
		if not is_tf_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_tf_distilbert import (
		    TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
		    TFDistilBertForMaskedLM,
		    TFDistilBertForMultipleChoice,
		    TFDistilBertForQuestionAnswering,
		    TFDistilBertForSequenceClassification,
		    TFDistilBertForTokenClassification,
		    TFDistilBertMainLayer,
		    TFDistilBertModel,
		    TFDistilBertPreTrainedModel,
		)

	try:
		if not is_flax_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_flax_distilbert import (
		    FlaxDistilBertForMaskedLM,
		    FlaxDistilBertForMultipleChoice,
		    FlaxDistilBertForQuestionAnswering,
		    FlaxDistilBertForSequenceClassification,
		    FlaxDistilBertForTokenClassification,
		    FlaxDistilBertModel,
		    FlaxDistilBertPreTrainedModel,
		)

else:
	import sys

	__lowercase     :						int	=     _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)



