





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


__lowerCamelCase :  List[str]										=  (
    """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_       (  _lowerCAmelCase							,     _lowerCAmelCase  ):
 warnings.warn(__A							,     __A  )
 requires_backends(__A							,     "sklearn"  )
 return (preds == labels).mean()



def 	A_       (  _lowerCAmelCase							,     _lowerCAmelCase  ):
 warnings.warn(__A							,     __A  )
 requires_backends(__A							,     "sklearn"  )
 UpperCamelCase			:      str 			=     simple_accuracy(__A							,     __A  )
 UpperCamelCase			:      List[Any] 			=     fa_score(y_true=__A							,     y_pred=__A  )
 return {
     "acc": acc,
     "f1": fa,
     "acc_and_f1": (acc + fa) / 2,
 }



def 	A_       (  _lowerCAmelCase							,     _lowerCAmelCase  ):
 warnings.warn(__A							,     __A  )
 requires_backends(__A							,     "sklearn"  )
 UpperCamelCase			:      List[str] 			=     pearsonr(__A							,     __A  )[0]
 UpperCamelCase			:      List[Any] 			=     spearmanr(__A							,     __A  )[0]
 return {
     "pearson": pearson_corr,
     "spearmanr": spearman_corr,
     "corr": (pearson_corr + spearman_corr) / 2,
 }



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



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







from typing import TYPE_CHECKING

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


__lowerCamelCase :  Union[str, Any]										=  {
    """configuration_vision_encoder_decoder""": ["""VisionEncoderDecoderConfig""", """VisionEncoderDecoderOnnxConfig"""]
}

try:
    if not is_torch_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    __lowerCamelCase :  Dict										=  ["""VisionEncoderDecoderModel"""]

try:
    if not is_tf_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    __lowerCamelCase :  List[str]										=  ["""TFVisionEncoderDecoderModel"""]

try:
    if not is_flax_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    __lowerCamelCase :  int										=  ["""FlaxVisionEncoderDecoderModel"""]

if TYPE_CHECKING:
    from .configuration_vision_encoder_decoder import VisionEncoderDecoderConfig, VisionEncoderDecoderOnnxConfig

    try:
        if not is_torch_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_vision_encoder_decoder import VisionEncoderDecoderModel

    try:
        if not is_tf_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_tf_vision_encoder_decoder import TFVisionEncoderDecoderModel

    try:
        if not is_flax_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_flax_vision_encoder_decoder import FlaxVisionEncoderDecoderModel

else:
    import sys

    __lowerCamelCase :  str										=  _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)
