


'''simple docstring'''


from sklearn.metrics import mean_squared_error

import datasets


lowerCamelCase__					=   '\\n@article{scikit-learn,\n title={Scikit-learn: Machine Learning in {P}ython},\n author={Pedregosa, F. and Varoquaux, G. and Gramfort, A. and Michel, V.\n         and Thirion, B. and Grisel, O. and Blondel, M. and Prettenhofer, P.\n         and Weiss, R. and Dubourg, V. and Vanderplas, J. and Passos, A. and\n         Cournapeau, D. and Brucher, M. and Perrot, M. and Duchesnay, E.},\n journal={Journal of Machine Learning Research},\n volume={12},\n pages={2825--2830},\n year={2011}\n}\n'

lowerCamelCase__					=   '\\nMean Squared Error(MSE) is the average of the square of difference between the predicted\nand actual values.\n'


lowerCamelCase__					=   '\nArgs:\n    predictions: array-like of shape (n_samples,) or (n_samples, n_outputs)\n        Estimated target values.\n    references: array-like of shape (n_samples,) or (n_samples, n_outputs)\n        Ground truth (correct) target values.\n    sample_weight: array-like of shape (n_samples,), default=None\n        Sample weights.\n    multioutput: {"raw_values", "uniform_average"} or array-like of shape (n_outputs,), default="uniform_average"\n        Defines aggregating of multiple output values. Array-like value defines weights used to average errors.\n\n        "raw_values" : Returns a full set of errors in case of multioutput input.\n\n        "uniform_average" : Errors of all outputs are averaged with uniform weight.\n\n    squared : bool, default=True\n        If True returns MSE value, if False returns RMSE (Root Mean Squared Error) value.\n\nReturns:\n    mse : mean squared error.\nExamples:\n\n    >>> mse_metric = datasets.load_metric("mse")\n    >>> predictions = [2.5, 0.0, 2, 8]\n    >>> references = [3, -0.5, 2, 7]\n    >>> results = mse_metric.compute(predictions=predictions, references=references)\n    >>> print(results)\n    {\'mse\': 0.375}\n    >>> rmse_result = mse_metric.compute(predictions=predictions, references=references, squared=False)\n    >>> print(rmse_result)\n    {\'mse\': 0.6123724356957945}\n\n    If you\'re using multi-dimensional lists, then set the config as follows :\n\n    >>> mse_metric = datasets.load_metric("mse", "multilist")\n    >>> predictions = [[0.5, 1], [-1, 1], [7, -6]]\n    >>> references = [[0, 2], [-1, 2], [8, -5]]\n    >>> results = mse_metric.compute(predictions=predictions, references=references)\n    >>> print(results)\n    {\'mse\': 0.7083333333333334}\n    >>> results = mse_metric.compute(predictions=predictions, references=references, multioutput=\'raw_values\')\n    >>> print(results) # doctest: +NORMALIZE_WHITESPACE\n    {\'mse\': array([0.41666667, 1. ])}\n'






@datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION			,				_KWARGS_DESCRIPTION		)
class 		lowerCAmelCase__	(	datasets.Metric		):




			def 							lowerCAmelCase__			(						self     :   Dict       )      ->Optional[Any]:



					'''simple docstring'''







					return datasets.MetricInfo(
					    description=_DESCRIPTION		,     citation=_CITATION		,     inputs_description=_KWARGS_DESCRIPTION		,     features=datasets.Features(self._get_feature_types()       )		,     reference_urls=[
					        "https://scikit-learn.org/stable/modules/generated/sklearn.metrics.mean_squared_error.html"
					    ]		,     )




			def 							lowerCAmelCase__			(						self     :   List[str]       )      ->str:



					'''simple docstring'''







					if self.config_name == "multilist":
							return {
							    "predictions": datasets.Sequence(datasets.Value("float"       )       ),
							    "references": datasets.Sequence(datasets.Value("float"       )       ),
							}
					else:
							return {
							    "predictions": datasets.Value("float"       ),
							    "references": datasets.Value("float"       ),
							}






			def 							lowerCAmelCase__			(						self     :   Optional[int]		,     lowerCamelCase__     :   Optional[Any]		,     lowerCamelCase__     :   str		,     lowerCamelCase__     :   Dict=None		,     lowerCamelCase__     :   Tuple="uniform_average"		,     lowerCamelCase__     :   Any=True       )      ->str:



					'''simple docstring'''







					_UpperCAmelCase						:				Any	    =					mean_squared_error(
					    lowerCamelCase__		,     lowerCamelCase__		,     sample_weight=lowerCamelCase__		,     multioutput=lowerCamelCase__		,     squared=lowerCamelCase__       )

					return {"mse": mse}







'''simple docstring'''


import copy

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


lowerCamelCase__					=   logging.get_logger(__name__)

lowerCamelCase__					=   {
    'ut/deta': 'https://huggingface.co/ut/deta/resolve/main/config.json',
}






class 		lowerCAmelCase__	(	UpperCAmelCase__		):
			lowerCAmelCase       :		Any				      =   "deta"
			lowerCAmelCase       :		Union[str, Any]				      =   {
			    "hidden_size": "d_model",
			    "num_attention_heads": "encoder_attention_heads",
			}




			def __init__(						self     :   Optional[Any]		,     lowerCamelCase__     :   str=None		,     lowerCamelCase__     :   str=9_00		,     lowerCamelCase__     :   Any=20_48		,     lowerCamelCase__     :   Optional[int]=6		,     lowerCamelCase__     :   str=20_48		,     lowerCamelCase__     :   Dict=8		,     lowerCamelCase__     :   Any=6		,     lowerCamelCase__     :   Union[str, Any]=10_24		,     lowerCamelCase__     :   Optional[int]=8		,     lowerCamelCase__     :   List[Any]=0.0		,     lowerCamelCase__     :   Tuple=True		,     lowerCamelCase__     :   int="relu"		,     lowerCamelCase__     :   str=2_56		,     lowerCamelCase__     :   Dict=0.1		,     lowerCamelCase__     :   Dict=0.0		,     lowerCamelCase__     :   Dict=0.0		,     lowerCamelCase__     :   Optional[int]=0.0_2		,     lowerCamelCase__     :   List[Any]=1.0		,     lowerCamelCase__     :   Optional[int]=True		,     lowerCamelCase__     :   Any=False		,     lowerCamelCase__     :   Any="sine"		,     lowerCamelCase__     :   str=5		,     lowerCamelCase__     :   Optional[int]=4		,     lowerCamelCase__     :   int=4		,     lowerCamelCase__     :   Optional[Any]=True		,     lowerCamelCase__     :   Dict=3_00		,     lowerCamelCase__     :   int=True		,     lowerCamelCase__     :   Dict=True		,     lowerCamelCase__     :   Union[str, Any]=1		,     lowerCamelCase__     :   Any=5		,     lowerCamelCase__     :   List[Any]=2		,     lowerCamelCase__     :   Union[str, Any]=1		,     lowerCamelCase__     :   str=1		,     lowerCamelCase__     :   Union[str, Any]=5		,     lowerCamelCase__     :   str=2		,     lowerCamelCase__     :   Optional[Any]=0.1		,     lowerCamelCase__     :   Union[str, Any]=0.2_5		,     **lowerCamelCase__     :   Optional[Any]		,     )      ->List[str]:



					'''simple docstring'''







					if backbone_config is None:
							logger.info("`backbone_config` is `None`. Initializing the config with the default `ResNet` backbone."       )
							_UpperCAmelCase						:				int	    =					CONFIG_MAPPING["resnet"](out_features=["stage2", "stage3", "stage4"]       )
					else:
							if isinstance(lowerCamelCase__		,     lowerCamelCase__       ):
									_UpperCAmelCase						:				Any	    =					backbone_config.pop("model_type"       )
									_UpperCAmelCase						:				Optional[int]	    =					CONFIG_MAPPING[backbone_model_type]
									_UpperCAmelCase						:				List[str]	    =					config_class.from_dict(lowerCamelCase__       )

					_UpperCAmelCase						:				Optional[Any]	    =					backbone_config
					_UpperCAmelCase						:				Optional[int]	    =					num_queries
					_UpperCAmelCase						:				Union[str, Any]	    =					max_position_embeddings
					_UpperCAmelCase						:				Union[str, Any]	    =					d_model
					_UpperCAmelCase						:				str	    =					encoder_ffn_dim
					_UpperCAmelCase						:				Optional[int]	    =					encoder_layers
					_UpperCAmelCase						:				int	    =					encoder_attention_heads
					_UpperCAmelCase						:				Union[str, Any]	    =					decoder_ffn_dim
					_UpperCAmelCase						:				Tuple	    =					decoder_layers
					_UpperCAmelCase						:				Union[str, Any]	    =					decoder_attention_heads
					_UpperCAmelCase						:				Any	    =					dropout
					_UpperCAmelCase						:				List[str]	    =					attention_dropout
					_UpperCAmelCase						:				Union[str, Any]	    =					activation_dropout
					_UpperCAmelCase						:				Optional[int]	    =					activation_function
					_UpperCAmelCase						:				str	    =					init_std
					_UpperCAmelCase						:				Tuple	    =					init_xavier_std
					_UpperCAmelCase						:				Optional[Any]	    =					encoder_layerdrop
					_UpperCAmelCase						:				int	    =					auxiliary_loss
					_UpperCAmelCase						:				Union[str, Any]	    =					position_embedding_type
					# deformable attributes
					_UpperCAmelCase						:				List[Any]	    =					num_feature_levels
					_UpperCAmelCase						:				List[Any]	    =					encoder_n_points
					_UpperCAmelCase						:				Tuple	    =					decoder_n_points
					_UpperCAmelCase						:				Optional[int]	    =					two_stage
					_UpperCAmelCase						:				Dict	    =					two_stage_num_proposals
					_UpperCAmelCase						:				int	    =					with_box_refine
					_UpperCAmelCase						:				str	    =					assign_first_stage
					if two_stage is True and with_box_refine is False:
							raise ValueError("If two_stage is True, with_box_refine must be True."       )
					# Hungarian matcher
					_UpperCAmelCase						:				Optional[int]	    =					class_cost
					_UpperCAmelCase						:				Dict	    =					bbox_cost
					_UpperCAmelCase						:				int	    =					giou_cost
					# Loss coefficients
					_UpperCAmelCase						:				int	    =					mask_loss_coefficient
					_UpperCAmelCase						:				List[Any]	    =					dice_loss_coefficient
					_UpperCAmelCase						:				Dict	    =					bbox_loss_coefficient
					_UpperCAmelCase						:				int	    =					giou_loss_coefficient
					_UpperCAmelCase						:				Optional[Any]	    =					eos_coefficient
					_UpperCAmelCase						:				int	    =					focal_alpha
					super().__init__(is_encoder_decoder=lowerCamelCase__		,     **lowerCamelCase__       )




			@property
			def 							lowerCAmelCase__			(						self     :   int       )      ->int:



					'''simple docstring'''







					return self.encoder_attention_heads




			@property
			def 							lowerCAmelCase__			(						self     :   List[Any]       )      ->int:



					'''simple docstring'''







					return self.d_model






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



					'''simple docstring'''







					_UpperCAmelCase						:				Optional[int]	    =					copy.deepcopy(self.__dict__       )
					_UpperCAmelCase						:				Tuple	    =					self.backbone_config.to_dict()
					_UpperCAmelCase						:				List[Any]	    =					self.__class__.model_type
					return output



