



from sklearn.metrics import recall_score

import datasets


snake_case__					:     Optional[int]    		=   """
Recall is the fraction of the positive examples that were correctly labeled by the model as positive. It can be computed with the equation:
Recall = TP / (TP + FN)
Where TP is the true positives and FN is the false negatives.
"""


snake_case__					:     int    		=   """
Args:
- **predictions** (`list` of `int`): The predicted labels.
- **references** (`list` of `int`): The ground truth labels.
- **labels** (`list` of `int`): The set of labels to include when `average` is not set to `binary`, and their order when average is `None`. Labels present in the data can be excluded in this input, for example to calculate a multiclass average ignoring a majority negative class, while labels not present in the data will result in 0 components in a macro average. For multilabel targets, labels are column indices. By default, all labels in y_true and y_pred are used in sorted order. Defaults to None.
- **pos_label** (`int`): The class label to use as the 'positive class' when calculating the recall. Defaults to `1`.
- **average** (`string`): This parameter is required for multiclass/multilabel targets. If None, the scores for each class are returned. Otherwise, this determines the type of averaging performed on the data. Defaults to `'binary'`.
    - `'binary'`: Only report results for the class specified by `pos_label`. This is applicable only if the target labels and predictions are binary.
    - `'micro'`: Calculate metrics globally by counting the total true positives, false negatives, and false positives.
    - `'macro'`: Calculate metrics for each label, and find their unweighted mean. This does not take label imbalance into account.
    - `'weighted'`: Calculate metrics for each label, and find their average weighted by support (the number of true instances for each label). This alters `'macro'` to account for label imbalance. Note that it can result in an F-score that is not between precision and recall.
    - `'samples'`: Calculate metrics for each instance, and find their average (only meaningful for multilabel classification).
- **sample_weight** (`list` of `float`): Sample weights Defaults to `None`.
- **zero_division** (): Sets the value to return when there is a zero division. Defaults to .
    - `'warn'`: If there is a zero division, the return value is `0`, but warnings are also raised.
    - `0`: If there is a zero division, the return value is `0`.
    - `1`: If there is a zero division, the return value is `1`.

Returns:
- **recall** (`float`, or `array` of `float`): Either the general recall score, or the recall scores for individual classes, depending on the values input to `labels` and `average`. Minimum possible value is 0. Maximum possible value is 1. A higher recall means that more of the positive examples have been labeled correctly. Therefore, a higher recall is generally considered better.

Examples:

    Example 1-A simple example with some errors
        >>> recall_metric = datasets.load_metric('recall')
        >>> results = recall_metric.compute(references=[0, 0, 1, 1, 1], predictions=[0, 1, 0, 1, 1])
        >>> print(results)
        {'recall': 0.6666666666666666}

    Example 2-The same example as Example 1, but with `pos_label=0` instead of the default `pos_label=1`.
        >>> recall_metric = datasets.load_metric('recall')
        >>> results = recall_metric.compute(references=[0, 0, 1, 1, 1], predictions=[0, 1, 0, 1, 1], pos_label=0)
        >>> print(results)
        {'recall': 0.5}

    Example 3-The same example as Example 1, but with `sample_weight` included.
        >>> recall_metric = datasets.load_metric('recall')
        >>> sample_weight = [0.9, 0.2, 0.9, 0.3, 0.8]
        >>> results = recall_metric.compute(references=[0, 0, 1, 1, 1], predictions=[0, 1, 0, 1, 1], sample_weight=sample_weight)
        >>> print(results)
        {'recall': 0.55}

    Example 4-A multiclass example, using different averages.
        >>> recall_metric = datasets.load_metric('recall')
        >>> predictions = [0, 2, 1, 0, 0, 1]
        >>> references = [0, 1, 2, 0, 1, 2]
        >>> results = recall_metric.compute(predictions=predictions, references=references, average='macro')
        >>> print(results)
        {'recall': 0.3333333333333333}
        >>> results = recall_metric.compute(predictions=predictions, references=references, average='micro')
        >>> print(results)
        {'recall': 0.3333333333333333}
        >>> results = recall_metric.compute(predictions=predictions, references=references, average='weighted')
        >>> print(results)
        {'recall': 0.3333333333333333}
        >>> results = recall_metric.compute(predictions=predictions, references=references, average=None)
        >>> print(results)
        {'recall': array([1., 0., 0.])}
"""


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

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


						'''simple docstring'''





						def     _snake_case	(	self	:							Tuple	):






							'''simple docstring'''



							return datasets.MetricInfo(
							    description=_DESCRIPTION							,      citation=_CITATION							,      inputs_description=_KWARGS_DESCRIPTION							,      features=datasets.Features(
							        {
							            "predictions": datasets.Sequence(datasets.Value("int32"	)	),
							            "references": datasets.Sequence(datasets.Value("int32"	)	),
							        }
							        if self.config_name == "multilabel"
							        else {
							            "predictions": datasets.Value("int32"	),
							            "references": datasets.Value("int32"	),
							        }	)							,      reference_urls=["https://scikit-learn.org/stable/modules/generated/sklearn.metrics.recall_score.html"]							,      )



						def     _snake_case	(	self	:							Union[str, Any]							,      lowerCamelCase	:							Tuple							,      lowerCamelCase	:							List[Any]							,      lowerCamelCase	:							Optional[int]=None							,      lowerCamelCase	:							List[Any]=1							,      lowerCamelCase	:							List[str]="binary"							,      lowerCamelCase	:							Tuple=None							,      lowerCamelCase	:							Tuple="warn"							,      ):






							'''simple docstring'''



							__lowercase		       =			recall_score(
							    lowerCamelCase							,      lowerCamelCase							,      labels=lowerCamelCase							,      pos_label=lowerCamelCase							,      average=lowerCamelCase							,      sample_weight=lowerCamelCase							,      zero_division=lowerCamelCase							,      )
							return {"recall": float(lowerCamelCase	) if score.size == 1 else score}








import copy
from collections import OrderedDict
from typing import Mapping

from packaging import version

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


snake_case__					:     int    		=   logging.get_logger(__name__)

snake_case__					:     Optional[int]    		=   {
    """microsoft/conditional-detr-resnet-50""": (
        """https://huggingface.co/microsoft/conditional-detr-resnet-50/resolve/main/config.json"""
    ),
}

class   _A   ( _lowercase	):


						'''simple docstring'''





						_snake_case			:     Dict      							=      """conditional_detr"""
						_snake_case			:     Union[str, Any]      							=      ["""past_key_values"""]
						_snake_case			:     Optional[int]      							=      {
						    """hidden_size""": """d_model""",
						    """num_attention_heads""": """encoder_attention_heads""",
						}



						def __init__(	self	:							Optional[Any]							,      lowerCamelCase	:							int=True							,      lowerCamelCase	:							Tuple=None							,      lowerCamelCase	:							Optional[int]=3							,      lowerCamelCase	:							Optional[int]=300							,      lowerCamelCase	:							List[Any]=6							,      lowerCamelCase	:							str=2_048							,      lowerCamelCase	:							Any=8							,      lowerCamelCase	:							List[str]=6							,      lowerCamelCase	:							Any=2_048							,      lowerCamelCase	:							List[Any]=8							,      lowerCamelCase	:							Optional[Any]=0.0							,      lowerCamelCase	:							List[str]=0.0							,      lowerCamelCase	:							List[Any]=True							,      lowerCamelCase	:							str="relu"							,      lowerCamelCase	:							int=256							,      lowerCamelCase	:							Dict=0.1							,      lowerCamelCase	:							Optional[Any]=0.0							,      lowerCamelCase	:							Dict=0.0							,      lowerCamelCase	:							Tuple=0.02							,      lowerCamelCase	:							int=1.0							,      lowerCamelCase	:							Tuple=False							,      lowerCamelCase	:							List[str]="sine"							,      lowerCamelCase	:							List[Any]="resnet50"							,      lowerCamelCase	:							Any=True							,      lowerCamelCase	:							Any=False							,      lowerCamelCase	:							List[Any]=2							,      lowerCamelCase	:							List[Any]=5							,      lowerCamelCase	:							str=2							,      lowerCamelCase	:							Dict=1							,      lowerCamelCase	:							List[str]=1							,      lowerCamelCase	:							Union[str, Any]=2							,      lowerCamelCase	:							Dict=5							,      lowerCamelCase	:							List[Any]=2							,      lowerCamelCase	:							Tuple=0.25							,      **lowerCamelCase	:							List[str]							,      ):






							'''simple docstring'''



							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."	)
									__lowercase		       =			CONFIG_MAPPING["resnet"](out_features=["stage4"]	)
								elif isinstance(lowerCamelCase							,      lowerCamelCase	):
									__lowercase		       =			backbone_config.get("model_type"	)
									__lowercase		       =			CONFIG_MAPPING[backbone_model_type]
									__lowercase		       =			config_class.from_dict(lowerCamelCase	)

							__lowercase		       =			use_timm_backbone
							__lowercase		       =			backbone_config
							__lowercase		       =			num_channels
							__lowercase		       =			num_queries
							__lowercase		       =			d_model
							__lowercase		       =			encoder_ffn_dim
							__lowercase		       =			encoder_layers
							__lowercase		       =			encoder_attention_heads
							__lowercase		       =			decoder_ffn_dim
							__lowercase		       =			decoder_layers
							__lowercase		       =			decoder_attention_heads
							__lowercase		       =			dropout
							__lowercase		       =			attention_dropout
							__lowercase		       =			activation_dropout
							__lowercase		       =			activation_function
							__lowercase		       =			init_std
							__lowercase		       =			init_xavier_std
							__lowercase		       =			encoder_layerdrop
							__lowercase		       =			decoder_layerdrop
							__lowercase		       =			encoder_layers
							__lowercase		       =			auxiliary_loss
							__lowercase		       =			position_embedding_type
							__lowercase		       =			backbone
							__lowercase		       =			use_pretrained_backbone
							__lowercase		       =			dilation
							# Hungarian matcher
							__lowercase		       =			class_cost
							__lowercase		       =			bbox_cost
							__lowercase		       =			giou_cost
							# Loss coefficients
							__lowercase		       =			mask_loss_coefficient
							__lowercase		       =			dice_loss_coefficient
							__lowercase		       =			cls_loss_coefficient
							__lowercase		       =			bbox_loss_coefficient
							__lowercase		       =			giou_loss_coefficient
							__lowercase		       =			focal_alpha
							super().__init__(is_encoder_decoder=lowerCamelCase							,      **lowerCamelCase	)



						@property
						def     _snake_case	(	self	:							Tuple	):






							'''simple docstring'''



							return self.encoder_attention_heads



						@property
						def     _snake_case	(	self	:							str	):






							'''simple docstring'''



							return self.d_model



						def     _snake_case	(	self	:							int	):






							'''simple docstring'''



							__lowercase		       =			copy.deepcopy(self.__dict__	)
							if self.backbone_config is not None:
								__lowercase		       =			self.backbone_config.to_dict()
							__lowercase		       =			self.__class__.model_type
							return output

class   _A   ( _lowercase	):


						'''simple docstring'''





						_snake_case			:     Any      							=      version.parse("""1.11"""	)



						@property
						def     _snake_case	(	self	:							Tuple	):






							'''simple docstring'''



							return OrderedDict(
							    [
							        ("pixel_values", {0: "batch", 1: "num_channels", 2: "height", 3: "width"}),
							        ("pixel_mask", {0: "batch"}),
							    ]	)



						@property
						def     _snake_case	(	self	:							Any	):






							'''simple docstring'''



							return 1e-5



						@property
						def     _snake_case	(	self	:							Optional[Any]	):






							'''simple docstring'''



							return 12



