





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					:    Optional[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        _a						(    UpperCAmelCase			,  UpperCAmelCase     )				->				int:







   """simple docstring"""
   warnings.warn(_lowercase			,  _lowercase     )
   requires_backends(_lowercase			,  '''sklearn'''     )
   return (preds == labels).mean()



def        _a						(    UpperCAmelCase			,  UpperCAmelCase     )				->				str:







   """simple docstring"""
   warnings.warn(_lowercase			,  _lowercase     )
   requires_backends(_lowercase			,  '''sklearn'''     )
   lowerCamelCase__   :						Tuple					   =							simple_accuracy(_lowercase			,  _lowercase     )
   lowerCamelCase__   :						Optional[int]					   =							fa_score(y_true=_lowercase			,  y_pred=_lowercase     )
   return {
       "acc": acc,
       "f1": fa,
       "acc_and_f1": (acc + fa) / 2,
   }



def        _a						(    UpperCAmelCase			,  UpperCAmelCase     )				->				Optional[Any]:







   """simple docstring"""
   warnings.warn(_lowercase			,  _lowercase     )
   requires_backends(_lowercase			,  '''sklearn'''     )
   lowerCamelCase__   :						Any					   =							pearsonr(_lowercase			,  _lowercase     )[0]
   lowerCamelCase__   :						List[str]					   =							spearmanr(_lowercase			,  _lowercase     )[0]
   return {
       "pearson": pearson_corr,
       "spearmanr": spearman_corr,
       "corr": (pearson_corr + spearman_corr) / 2,
   }



def        _a						(    UpperCAmelCase			,  UpperCAmelCase			,  UpperCAmelCase     )				->				List[Any]:







   """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        _a						(    UpperCAmelCase			,  UpperCAmelCase			,  UpperCAmelCase     )				->				Tuple:







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




from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


__UpperCamelCase		:       int									=     {'configuration_yolos': ['YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP', 'YolosConfig', 'YolosOnnxConfig']}

try:
					if not is_vision_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					__UpperCamelCase		:       int									=     ['YolosFeatureExtractor']
					__UpperCamelCase		:       Union[str, Any]									=     ['YolosImageProcessor']

try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					__UpperCamelCase		:       str									=     [
					    'YOLOS_PRETRAINED_MODEL_ARCHIVE_LIST',
					    'YolosForObjectDetection',
					    'YolosModel',
					    'YolosPreTrainedModel',
					]


if TYPE_CHECKING:
					from .configuration_yolos import YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP, YolosConfig, YolosOnnxConfig

					try:
										if not is_vision_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .feature_extraction_yolos import YolosFeatureExtractor
										from .image_processing_yolos import YolosImageProcessor

					try:
										if not is_torch_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_yolos import (
										    YOLOS_PRETRAINED_MODEL_ARCHIVE_LIST,
										    YolosForObjectDetection,
										    YolosModel,
										    YolosPreTrainedModel,
										)


else:
					import sys

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





