

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


a        =						(
    "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 						__magic_name__       (							__UpperCAmelCase							,	__UpperCAmelCase      )						->					Dict:

   '''simple docstring'''







   warnings.warn(lowerCamelCase_							,	lowerCamelCase_      )
   requires_backends(lowerCamelCase_							,	"""sklearn"""      )
   return (preds == labels).mean()

def 						__magic_name__       (							__UpperCAmelCase							,	__UpperCAmelCase      )						->					Tuple:

   '''simple docstring'''







   warnings.warn(lowerCamelCase_							,	lowerCamelCase_      )
   requires_backends(lowerCamelCase_							,	"""sklearn"""      )
   __SCREAMING_SNAKE_CASE      							=       simple_accuracy(lowerCamelCase_							,	lowerCamelCase_      )
   __SCREAMING_SNAKE_CASE      							=       fa_score(y_true=lowerCamelCase_							,	y_pred=lowerCamelCase_      )
   return {
       "acc": acc,
       "f1": fa,
       "acc_and_f1": (acc + fa) / 2,
   }

def 						__magic_name__       (							__UpperCAmelCase							,	__UpperCAmelCase      )						->					Tuple:

   '''simple docstring'''







   warnings.warn(lowerCamelCase_							,	lowerCamelCase_      )
   requires_backends(lowerCamelCase_							,	"""sklearn"""      )
   __SCREAMING_SNAKE_CASE      							=       pearsonr(lowerCamelCase_							,	lowerCamelCase_      )[0]
   __SCREAMING_SNAKE_CASE      							=       spearmanr(lowerCamelCase_							,	lowerCamelCase_      )[0]
   return {
       "pearson": pearson_corr,
       "spearmanr": spearman_corr,
       "corr": (pearson_corr + spearman_corr) / 2,
   }

def 						__magic_name__       (							__UpperCAmelCase							,	__UpperCAmelCase							,	__UpperCAmelCase      )						->					Any:

   '''simple docstring'''







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







def 						__magic_name__       (							__UpperCAmelCase							,	__UpperCAmelCase							,	__UpperCAmelCase      )						->					Any:

   '''simple docstring'''







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












'''simple docstring'''

from ...utils import (
    OptionalDependencyNotAvailable,
    is_flax_available,
    is_torch_available,
    is_transformers_available,
)


try:
    if not (is_transformers_available() and is_torch_available()):
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    from ...utils.dummy_torch_and_transformers_objects import *  # noqa F403
else:
    from .multicontrolnet import MultiControlNetModel
    from .pipeline_controlnet import StableDiffusionControlNetPipeline
    from .pipeline_controlnet_imgaimg import StableDiffusionControlNetImgaImgPipeline
    from .pipeline_controlnet_inpaint import StableDiffusionControlNetInpaintPipeline


if is_transformers_available() and is_flax_available():
    from .pipeline_flax_controlnet import FlaxStableDiffusionControlNetPipeline





