


'''simple docstring'''





import copy
from collections import OrderedDict
from typing import Dict, Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging
from ..auto import CONFIG_MAPPING


UpperCAmelCase__  			=				logging.get_logger(__name__)

UpperCAmelCase__  			=				{
    '''facebook/detr-resnet-50''': '''https://huggingface.co/facebook/detr-resnet-50/resolve/main/config.json''',
    # See all DETR models at https://huggingface.co/models?filter=detr
}
class 						a__					(					__lowercase   ):





			'''simple docstring'''

			A						:				Optional[Any]					      =			"detr"
			A						:				int					      =			["past_key_values"]
			A						:				int					      =			{
			    "hidden_size": "d_model",
			    "num_attention_heads": "encoder_attention_heads",
			}
			def __init__(  self							:			Optional[int]			,    lowerCAmelCase_							:			List[str]=True			,    lowerCAmelCase_							:			List[Any]=None			,    lowerCAmelCase_							:			str=3			,    lowerCAmelCase_							:			Dict=100			,    lowerCAmelCase_							:			Optional[int]=6			,    lowerCAmelCase_							:			Optional[Any]=2_048			,    lowerCAmelCase_							:			Any=8			,    lowerCAmelCase_							:			List[str]=6			,    lowerCAmelCase_							:			Dict=2_048			,    lowerCAmelCase_							:			int=8			,    lowerCAmelCase_							:			str=0.0			,    lowerCAmelCase_							:			List[str]=0.0			,    lowerCAmelCase_							:			Optional[Any]=True			,    lowerCAmelCase_							:			Optional[int]="relu"			,    lowerCAmelCase_							:			Optional[int]=256			,    lowerCAmelCase_							:			List[Any]=0.1			,    lowerCAmelCase_							:			Any=0.0			,    lowerCAmelCase_							:			Optional[int]=0.0			,    lowerCAmelCase_							:			Any=0.02			,    lowerCAmelCase_							:			List[Any]=1.0			,    lowerCAmelCase_							:			List[Any]=False			,    lowerCAmelCase_							:			Union[str, Any]="sine"			,    lowerCAmelCase_							:			Optional[Any]="resnet50"			,    lowerCAmelCase_							:			List[str]=True			,    lowerCAmelCase_							:			int=False			,    lowerCAmelCase_							:			Dict=1			,    lowerCAmelCase_							:			List[Any]=5			,    lowerCAmelCase_							:			Dict=2			,    lowerCAmelCase_							:			List[Any]=1			,    lowerCAmelCase_							:			List[Any]=1			,    lowerCAmelCase_							:			List[Any]=5			,    lowerCAmelCase_							:			List[str]=2			,    lowerCAmelCase_							:			Tuple=0.1			,    **lowerCAmelCase_							:			List[Any]			,    )      ->		Any:
						if backbone_config is not None and use_timm_backbone:
									raise ValueError('You can\'t specify both `backbone_config` and `use_timm_backbone`.'	)

						if not use_timm_backbone:
									if backbone_config is None:
												logger.info('`backbone_config` is `None`. Initializing the config with the default `ResNet` backbone.'	)
												__A=	CONFIG_MAPPING['''resnet'''](out_features=['stage4']	)
									elif isinstance(_a			,    _a	):
												__A=	backbone_config.get('model_type'	)
												__A=	CONFIG_MAPPING[backbone_model_type]
												__A=	config_class.from_dict(_a	)
									# set timm attributes to None
									__A=	None, None, None

						__A=	use_timm_backbone
						__A=	backbone_config
						__A=	num_channels
						__A=	num_queries
						__A=	d_model
						__A=	encoder_ffn_dim
						__A=	encoder_layers
						__A=	encoder_attention_heads
						__A=	decoder_ffn_dim
						__A=	decoder_layers
						__A=	decoder_attention_heads
						__A=	dropout
						__A=	attention_dropout
						__A=	activation_dropout
						__A=	activation_function
						__A=	init_std
						__A=	init_xavier_std
						__A=	encoder_layerdrop
						__A=	decoder_layerdrop
						__A=	encoder_layers
						__A=	auxiliary_loss
						__A=	position_embedding_type
						__A=	backbone
						__A=	use_pretrained_backbone
						__A=	dilation
						# Hungarian matcher
						__A=	class_cost
						__A=	bbox_cost
						__A=	giou_cost
						# Loss coefficients
						__A=	mask_loss_coefficient
						__A=	dice_loss_coefficient
						__A=	bbox_loss_coefficient
						__A=	giou_loss_coefficient
						__A=	eos_coefficient
						super().__init__(is_encoder_decoder=_a			,    **_a	)
			@property
			def 					lowerCAmelCase     (  self							:			Union[str, Any]	)      ->		int:
						return self.encoder_attention_heads
			@property
			def 					lowerCAmelCase     (  self							:			Optional[Any]	)      ->		int:
						return self.d_model
			@classmethod
			def 					lowerCAmelCase     (  cls							:			Union[str, Any]			,    lowerCAmelCase_							:			List[Any]			,    **lowerCAmelCase_							:			int	)      ->		Optional[int]:
						return cls(backbone_config=_a			,    **_a	)

			def 					lowerCAmelCase     (  self							:			Tuple	)      ->		Dict[str, any]:
						__A=	copy.deepcopy(self.__dict__	)
						if output["backbone_config"] is not None:
									__A=	self.backbone_config.to_dict()
						__A=	self.__class__.model_type
						return output


class 						a__					(					__lowercase   ):





			'''simple docstring'''

			A						:				List[str]					      =			version.parse('''1.11'''   )
			@property
			def 					lowerCAmelCase     (  self							:			Union[str, Any]	)      ->		Mapping[str, Mapping[int, str]]:
						return OrderedDict(
						    [
						        ('pixel_values', {0: 'batch', 1: 'num_channels', 2: 'height', 3: 'width'}),
						        ('pixel_mask', {0: 'batch'}),
						    ]	)
			@property
			def 					lowerCAmelCase     (  self							:			str	)      ->		float:
						return 1E-5

			@property
			def 					lowerCAmelCase     (  self							:			Union[str, Any]	)      ->		int:
						return 12






from scipy.stats import spearmanr

import datasets


a__												=						'''
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.
'''

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

a__												=						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 							UpperCAmelCase_						(     datasets.Metric  ):
							"""simple docstring"""







							def 							__lowercase							(     self			)       ->       int:
												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 							__lowercase							(     self			,				_a			,				_a			,				_a=False			)       ->       str:
												_a      :       int   =						spearmanr(_a			,				_a			)
												if return_pvalue:
																	return {"spearmanr": results[0], "spearmanr_pvalue": results[1]}
												else:
																	return {"spearmanr": results[0]}



