

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_	:			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 						UpperCamelCase (lowercase_:			Optional[Any]   ,				lowercase_:			Tuple )					->				List[str]:
	warnings.warn(lowercase_   ,				lowercase_ )
	requires_backends(lowercase_   ,				"""sklearn""" )
	return (preds == labels).mean()

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

def 						UpperCamelCase (lowercase_:			Tuple   ,				lowercase_:			Union[str, Any] )					->				Tuple:
	warnings.warn(lowercase_   ,				lowercase_ )
	requires_backends(lowercase_   ,				"""sklearn""" )
	A__							:   Union[str, Any]					       =		pearsonr(lowercase_   ,				lowercase_ )[0]
	A__							:   Optional[int]					       =		spearmanr(lowercase_   ,				lowercase_ )[0]
	return {
	    "pearson": pearson_corr,
	    "spearmanr": spearman_corr,
	    "corr": (pearson_corr + spearman_corr) / 2,
	}

def 						UpperCamelCase (lowercase_:			Dict   ,				lowercase_:			int   ,				lowercase_:			List[Any] )					->				List[Any]:
	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 						UpperCamelCase (lowercase_:			Dict   ,				lowercase_:			int   ,				lowercase_:			List[str] )					->				Optional[int]:
	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 ...configuration_utils import PretrainedConfig
from ...utils import logging


A_	:			str  	=      logging.get_logger(__name__)

A_	:			Any  	=      {
    'tiiuae/falcon-40b': 'https://huggingface.co/tiiuae/falcon-40b/resolve/main/config.json',
    'tiiuae/falcon-7b': 'https://huggingface.co/tiiuae/falcon-7b/resolve/main/config.json',
}



class    _a						(__magic_name__    ):


					'''simple docstring'''






					UpperCAmelCase__:       Dict  							=	'''falcon'''
					UpperCAmelCase__:       Any  							=	['''past_key_values''']






					def __init__(			self   ,	A__=6_5024   ,	A__=4544   ,	A__=32   ,	A__=71   ,	A__=1e-5   ,	A__=0.0_2   ,	A__=True   ,	A__=0.0   ,	A__=0.0   ,	A__=None   ,	A__=False   ,	A__=False   ,	A__=True   ,	A__=True   ,	A__=False   ,	A__=11   ,	A__=11   ,	**A__   ,	):
						A__							:   Dict					       =		vocab_size
						# Backward compatibility with n_embed kwarg
						A__							:   Union[str, Any]					       =		kwargs.pop("""n_embed"""   ,	A__      )
						A__							:   Optional[Any]					       =		hidden_size if n_embed is None else n_embed
						A__							:   Any					       =		num_hidden_layers
						A__							:   Any					       =		num_attention_heads
						A__							:   Optional[Any]					       =		layer_norm_epsilon
						A__							:   Tuple					       =		initializer_range
						A__							:   Tuple					       =		use_cache
						A__							:   str					       =		hidden_dropout
						A__							:   List[str]					       =		attention_dropout

						A__							:   List[Any]					       =		bos_token_id
						A__							:   Optional[Any]					       =		eos_token_id
						A__							:   Optional[Any]					       =		num_attention_heads if num_kv_heads is None else num_kv_heads
						A__							:   List[str]					       =		alibi
						A__							:   Tuple					       =		new_decoder_architecture
						A__							:   List[str]					       =		multi_query  # Ignored when new_decoder_architecture is True
						A__							:   List[Any]					       =		parallel_attn
						A__							:   int					       =		bias

						super().__init__(bos_token_id=A__   ,	eos_token_id=A__   ,	**A__      )






					@property
					def   __A      (			self      ):
						return self.hidden_size // self.num_attention_heads






					@property
					def   __A      (			self      ):
						return not self.alibi



