
'''simple docstring'''




from collections import OrderedDict
from typing import Any, Mapping, Optional

from ... import PreTrainedTokenizer, TensorType, is_torch_available
from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfigWithPast
from ...utils import logging


__lowerCamelCase   :					Any   							=					logging.get_logger(__name__)

__lowerCamelCase   :					str   							=					{
    '''EleutherAI/gpt-neo-1.3B''': '''https://huggingface.co/EleutherAI/gpt-neo-1.3B/resolve/main/config.json''',
    # See all GPTNeo models at https://huggingface.co/models?filter=gpt_neo
}







class    A_	(a_							):
							"""simple docstring"""




							a__   		=	'''gpt_neo'''
							a__   		=	['''past_key_values''']
							a__   		=	{'''num_attention_heads''': '''num_heads''', '''num_hidden_layers''': '''num_layers'''}

							def __init__(		self			:List[str]       ,							lowerCAmelCase__			:Tuple=50_257       ,							lowerCAmelCase__			:Optional[Any]=2_048       ,							lowerCAmelCase__			:Tuple=2_048       ,							lowerCAmelCase__			:Optional[int]=24       ,							lowerCAmelCase__			:List[str]=[[["global", "local"], 12]]       ,							lowerCAmelCase__			:Optional[int]=16       ,							lowerCAmelCase__			:List[Any]=None       ,							lowerCAmelCase__			:Dict=256       ,							lowerCAmelCase__			:Union[str, Any]="gelu_new"       ,							lowerCAmelCase__			:Dict=0.0       ,							lowerCAmelCase__			:Optional[Any]=0.0       ,							lowerCAmelCase__			:Union[str, Any]=0.0       ,							lowerCAmelCase__			:str=0.1       ,							lowerCAmelCase__			:Any=1E-5       ,							lowerCAmelCase__			:Optional[Any]=0.0_2       ,							lowerCAmelCase__			:Dict=True       ,							lowerCAmelCase__			:int=50_256       ,							lowerCAmelCase__			:Tuple=50_256       ,							**lowerCAmelCase__			:Any       ,							)				->  Tuple:


										'''simple docstring'''




										snake_case_				:					Dict   =       vocab_size
										snake_case_				:					Tuple   =       max_position_embeddings
										snake_case_				:					Tuple   =       hidden_size
										snake_case_				:					int   =       num_layers
										snake_case_				:					List[str]   =       num_heads
										snake_case_				:					List[Any]   =       intermediate_size
										snake_case_				:					str   =       window_size
										snake_case_				:					List[Any]   =       activation_function
										snake_case_				:					List[Any]   =       resid_dropout
										snake_case_				:					Union[str, Any]   =       embed_dropout
										snake_case_				:					List[str]   =       attention_dropout
										snake_case_				:					List[Any]   =       classifier_dropout
										snake_case_				:					List[Any]   =       layer_norm_epsilon
										snake_case_				:					Union[str, Any]   =       initializer_range
										snake_case_				:					Optional[int]   =       use_cache

										snake_case_				:					int   =       bos_token_id
										snake_case_				:					Dict   =       eos_token_id

										snake_case_				:					Any   =       attention_types
										snake_case_				:					Union[str, Any]   =       self.expand_attention_types_params(lowerCAmelCase__				)

										if len(self.attention_layers				) != self.num_layers:
													raise ValueError(
													    "Configuration for convolutional module is incorrect. "
													    "It is required that `len(config.attention_layers)` == `config.num_layers` "
													    F'''but is `len(config.attention_layers) = {len(self.attention_layers				)}`, '''
													    F'''`config.num_layers = {self.num_layers}`. '''
													    "`config.attention_layers` is prepared using `config.attention_types`. "
													    "Please verify the value of `config.attention_types` argument."				)

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






							@staticmethod
							def 							_A	(		lowerCAmelCase__			:Optional[Any]				)				->  Optional[Any]:


										'''simple docstring'''




										snake_case_				:					int   =       []
										for item in attention_types:
													for _ in range(item[1]				):
																attentions.extend(item[0]				)
										return attentions

def 	__UpperCAmelCase       ( __magic_name__     ,__magic_name__     ,__magic_name__     ,__magic_name__						)->    Union[str, Any]:



			"""simple docstring"""



			import torch

			snake_case_				:					Optional[Any]   =       input.size()
			snake_case_				:					Optional[int]   =       len(__magic_name__						)
			snake_case_				:					List[Any]   =       shape[dimension]

			snake_case_				:					List[Any]   =       torch.arange(0     ,__magic_name__     ,__magic_name__						)
			snake_case_				:					str   =       torch.div(sizedim - size     ,__magic_name__     ,rounding_mode="floor"						) + 1
			snake_case_				:					Dict   =       torch.arange(__magic_name__						) + low_indices[:min_length][:, None]

			snake_case_				:					List[str]   =       [slice(__magic_name__						)] * rank
			snake_case_				:					List[str]   =       indices
			snake_case_				:					Optional[Any]   =       input[s]

			snake_case_				:					List[str]   =       list(range(0     ,rank + 1						)						)
			perm.append(perm.pop(dimension + 1						)						)

			return sliced.permute(__magic_name__						)

def 	__UpperCAmelCase       ( __magic_name__     ,__magic_name__						)->    int:



			"""simple docstring"""



			import torch

			snake_case_				:					List[Any]   =       torch.arange(1     ,__magic_name__						)
			snake_case_				:					List[str]   =       torch.remainder(__magic_name__     ,__magic_name__						)
			snake_case_				:					Optional[int]   =       remainders == 0
			snake_case_				:					Union[str, Any]   =       candidates[divisor_indices]
			snake_case_				:					Any   =       torch.max(__magic_name__						)
			return largest_divisor, torch.div(__magic_name__     ,__magic_name__     ,rounding_mode="floor"						)







class    A_	(a_							):
							"""simple docstring"""




							@property
							def 							_A	(		self			:Optional[Any]				)				->  Mapping[str, Mapping[int, str]]:


										'''simple docstring'''




										snake_case_				:					str   =       OrderedDict({"input_ids": {0: "batch", 1: "sequence"}}				)
										if self.use_past:
													self.fill_with_past_key_values_(lowerCAmelCase__       ,							direction="inputs"				)
													snake_case_				:					str   =       {0: "batch", 1: "past_sequence + sequence"}
										else:
													snake_case_				:					Optional[Any]   =       {0: "batch", 1: "sequence"}

										return common_inputs

							@property
							def 							_A	(		self			:Optional[Any]				)				->  int:


										'''simple docstring'''




										return self._config.num_heads

							def 							_A	(		self			:Optional[int]       ,							lowerCAmelCase__			:PreTrainedTokenizer       ,							lowerCAmelCase__			:int = -1       ,							lowerCAmelCase__			:int = -1       ,							lowerCAmelCase__			:bool = False       ,							lowerCAmelCase__			:Optional[TensorType] = None       ,							)				->  Mapping[str, Any]:


										'''simple docstring'''




										snake_case_				:					Optional[Any]   =       super(lowerCAmelCase__       ,							self				).generate_dummy_inputs(
										    lowerCAmelCase__       ,							batch_size=lowerCAmelCase__       ,							seq_length=lowerCAmelCase__       ,							is_pair=lowerCAmelCase__       ,							framework=lowerCAmelCase__				)

										# We need to order the input in the way they appears in the forward()
										snake_case_				:					Union[str, Any]   =       OrderedDict({"input_ids": common_inputs["input_ids"]}				)

										# Need to add the past_keys
										if self.use_past:
													if not is_torch_available():
																raise ValueError("Cannot generate dummy past_keys inputs without PyTorch installed."				)
													else:
																import torch

																snake_case_				:					int   =       common_inputs["input_ids"].shape
																# Not using the same length for past_key_values
																snake_case_				:					List[str]   =       seqlen + 2
																snake_case_				:					int   =       (
																    batch,
																    self.num_attention_heads,
																    past_key_values_length,
																    self._config.hidden_size // self.num_attention_heads,
																)
																snake_case_				:					Union[str, Any]   =       [
																    (torch.zeros(lowerCAmelCase__				), torch.zeros(lowerCAmelCase__				)) for _ in range(self.num_layers				)
																]

										snake_case_				:					List[str]   =       common_inputs["attention_mask"]
										if self.use_past:
													snake_case_				:					Any   =       ordered_inputs["attention_mask"].dtype
													snake_case_				:					str   =       torch.cat(
													    [ordered_inputs["attention_mask"], torch.ones(lowerCAmelCase__       ,							lowerCAmelCase__       ,							dtype=lowerCAmelCase__				)]       ,							dim=1				)

										return ordered_inputs






							@property
							def 							_A	(		self			:Any				)				->  int:


										'''simple docstring'''




										return 13












'''simple docstring'''




from scipy.stats import spearmanr

import datasets


__lowerCamelCase   :					str   							=					'''
The Spearman rank-order correlation coefficient is a measure of the
relationship between two datasets. Like other correlation coefficients,
this one varies between -1 and +1 with 0 implying no correlation.
Positive correlations imply that as data in dataset x increases, so
does data in dataset y. Negative correlations imply that as x increases,
y decreases. Correlations of -1 or +1 imply an exact monotonic relationship.

Unlike the Pearson correlation, the Spearman correlation does not
assume that both datasets are normally distributed.

The p-value roughly indicates the probability of an uncorrelated system
producing datasets that have a Spearman correlation at least as extreme
as the one computed from these datasets. The p-values are not entirely
reliable but are probably reasonable for datasets larger than 500 or so.
'''

__lowerCamelCase   :					int   							=					'''
Args:
    predictions (`List[float]`): Predicted labels, as returned by a model.
    references (`List[float]`): Ground truth labels.
    return_pvalue (`bool`): If `True`, returns the p-value. If `False`, returns
            only the spearmanr score. Defaults to `False`.
Returns:
    spearmanr (`float`): Spearman correlation coefficient.
    p-value (`float`): p-value. **Note**: is only returned if `return_pvalue=True` is input.
Examples:
    Example 1:
        >>> spearmanr_metric = datasets.load_metric("spearmanr")
        >>> results = spearmanr_metric.compute(references=[1, 2, 3, 4, 5], predictions=[10, 9, 2.5, 6, 4])
        >>> print(results)
        {\'spearmanr\': -0.7}

    Example 2:
        >>> spearmanr_metric = datasets.load_metric("spearmanr")
        >>> results = spearmanr_metric.compute(references=[1, 2, 3, 4, 5],
        ...                                     predictions=[10, 9, 2.5, 6, 4],
        ...                                     return_pvalue=True)
        >>> print(results[\'spearmanr\'])
        -0.7
        >>> print(round(results[\'spearmanr_pvalue\'], 2))
        0.19
'''

__lowerCamelCase   :					List[str]   							=					R'''\
@book{kokoska2000crc,
  title={CRC standard probability and statistics tables and formulae},
  author={Kokoska, Stephen and Zwillinger, Daniel},
  year={2000},
  publisher={Crc Press}
}
@article{2020SciPy-NMeth,
  author  = {Virtanen, Pauli and Gommers, Ralf and Oliphant, Travis E. and
            Haberland, Matt and Reddy, Tyler and Cournapeau, David and
            Burovski, Evgeni and Peterson, Pearu and Weckesser, Warren and
            Bright, Jonathan and {van der Walt}, St{\'e}fan J. and
            Brett, Matthew and Wilson, Joshua and Millman, K. Jarrod and
            Mayorov, Nikolay and Nelson, Andrew R. J. and Jones, Eric and
            Kern, Robert and Larson, Eric and Carey, C J and
            Polat, {\.I}lhan and Feng, Yu and Moore, Eric W. and
            {VanderPlas}, Jake and Laxalde, Denis and Perktold, Josef and
            Cimrman, Robert and Henriksen, Ian and Quintero, E. A. and
            Harris, Charles R. and Archibald, Anne M. and
            Ribeiro, Ant{\^o}nio H. and Pedregosa, Fabian and
            {van Mulbregt}, Paul and {SciPy 1.0 Contributors}},
  title   = {{{SciPy} 1.0: Fundamental Algorithms for Scientific
            Computing in Python}},
  journal = {Nature Methods},
  year    = {2020},
  volume  = {17},
  pages   = {261--272},
  adsurl  = {https://rdcu.be/b08Wh},
  doi     = {10.1038/s41592-019-0686-2},
}
'''







@datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION						,					_KWARGS_DESCRIPTION							)
class    A_	(datasets.Metric							):
							"""simple docstring"""




							def 							_A	(		self			:str				)				->  Union[str, Any]:


										'''simple docstring'''




										return datasets.MetricInfo(
										    description=_DESCRIPTION       ,							citation=_CITATION       ,							inputs_description=_KWARGS_DESCRIPTION       ,							features=datasets.Features(
										        {
										            "predictions": datasets.Value("float"				),
										            "references": datasets.Value("float"				),
										        }				)       ,							reference_urls=["https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.spearmanr.html"]       ,							)






							def 							_A	(		self			:Optional[int]       ,							lowerCAmelCase__			:Optional[Any]       ,							lowerCAmelCase__			:int       ,							lowerCAmelCase__			:Optional[Any]=False				)				->  List[Any]:


										'''simple docstring'''




										snake_case_				:					Optional[Any]   =       spearmanr(lowerCAmelCase__       ,							lowerCAmelCase__				)
										if return_pvalue:
													return {"spearmanr": results[0], "spearmanr_pvalue": results[1]}
										else:
													return {"spearmanr": results[0]}




