Ë
    ýÿæi1�  ã            &       ó  — d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZ d dl	m
Z
mZmZmZmZmZmZ d dlZd dlZd dlmZ d dlmZ d dlmZ d d	lmZmZmZ esesd
dgZ	 	 d5deeeef      deeeef      deed   e ed   df   f   de!ddf
d„Z"dedefd„Z#	 d6deed   e ed   df   f   de ed   df   fd„Z$ded   de e%e%ef   fd„Z& G d„ d«      Z'de(ddfd„Z)	 d7deed   eed   df   f   dedee(   d e'd!eee
f   d"e!de ee   ee    f   fd#„Z*d$ee   d%ee   dee(   fd&„Z+d e'd%ee   d'ee   d(ee   d)ee   d*ee   d$ee   d+ee   d,ee   d-ee   deed   eed   df   f   d.ed/   d0ee,   d1ee,   dee(   d2e!d3e!deeef   f$d4„Z-y)8é    N)ÚSequence)Úversion)Ú
ModuleType)ÚAnyÚDictÚListÚLiteralÚOptionalÚTupleÚUnion)Úapply_to_collection)ÚTensor)Úrank_zero_warn)Ú_FASTER_COCO_EVAL_AVAILABLEÚ_PYCOCOTOOLS_AVAILABLEÚ _PYCOCOTOOLS_GREATER_EQUAL_2_0_9zCocoBackend.tm_to_cocozCocoBackend.coco_to_tmÚpredsÚtargetsÚiou_type©ÚbboxÚsegm.Úignore_scoreÚreturnc                 ó  ‡‡	‡
— t        |t        «      r|f}dddœŠ
t        ˆ
fd„|D «       «      rt        d|› d�«      ‚|D �cg c]  }‰
|   ‘Œ	 }}t        | t        «      st        d| › �«      ‚t        |t        «      st        d|› �«      ‚t        | «      t        |«      k7  r#t        d	t        | «      › d
t        |«      › �«      ‚g |¢d‘|sdgng z   D ]%  Š	t        ˆ	fd„| D «       «      sŒt        d‰	› d�«      ‚ g |¢d‘D ]%  Š	t        ˆ	fd„|D «       «      sŒt        d‰	› d�«      ‚ |D ]%  Št        ˆfd„| D «       «      rŒt        d‰› d�«      ‚ |st        d„ | D «       «      st        d«      ‚t        d„ | D «       «      st        d«      ‚|D ]%  Št        ˆfd„|D «       «      rŒt        d‰› d�«      ‚ t        d„ |D «       «      st        d«      ‚t        |«      D ]q  \  }}|D ]g  Š|‰   j                  d«      |d   j                  d«      k7  sŒ-t        d‰› d|› d |‰   j                  d«      › d!|d   j                  d«      › d"�	«      ‚ Œs |ry#t        | «      D ]   \  }}|D ]–  Š|‰   j                  d«      |d   j                  d«      cxk(  r|d   j                  d«      k(  rŒEn t        d‰› d$|› d%|‰   j                  d«      › d&|d   j                  d«      › d'|d   j                  d«      › d"�«      ‚ Œ¢ y#c c}w )(z9Ensure the correct input format of `preds` and `targets`.ÚboxesÚmasksr   c              3   ó&   •K  — | ]  }|‰v–— Œ
 y ­w©N© )Ú.0ÚtpÚname_maps     €ús/Volumes/fast/ai/experiments/voice-extract-mac/.venv/lib/python3.12/site-packages/torchmetrics/detection/helpers.pyÚ	<genexpr>z#_input_validator.<locals>.<genexpr>4   s   øè ø€ Ð
1© "ˆ2�XÔ©ùó   ƒz	IOU type z is not supportedz:Expected argument `preds` to be of type Sequence, but got z;Expected argument `target` to be of type Sequence, but got zHExpected argument `preds` and `target` to have the same length, but got z and ÚlabelsÚscoresc              3   ó&   •K  — | ]  }‰|v–— Œ
 y ­wr   r    ©r!   ÚpÚks     €r$   r%   z#_input_validator.<locals>.<genexpr>B   s   øè ø€ Ð)¡5˜aˆq˜Œz¡5ùr&   z.Expected all dicts in `preds` to contain the `z` keyc              3   ó&   •K  — | ]  }‰|v–— Œ
 y ­wr   r    r*   s     €r$   r%   z#_input_validator.<locals>.<genexpr>F   s   øè ø€ Ð+¡7˜aˆq˜Œz¡7ùr&   z/Expected all dicts in `target` to contain the `c              3   óD   •K  — | ]  }t        |‰   t        «      –— Œ y ­wr   ©Ú
isinstancer   )r!   ÚpredÚivns     €r$   r%   z#_input_validator.<locals>.<genexpr>J   s   øè ø€ ÐC¹U°T”:˜d 3™i¬×0¹Uùó   ƒ zExpected all z  in `preds` to be of type Tensorc              3   óB   K  — | ]  }t        |d    t        «      –— Œ y­w)r(   Nr/   ©r!   r1   s     r$   r%   z#_input_validator.<locals>.<genexpr>L   s   è ø€ Ð#YÑSXÈ4¤J¨t°H©~¼v×$FÑSXùó   ‚z3Expected all scores in `preds` to be of type Tensorc              3   óB   K  — | ]  }t        |d    t        «      –— Œ y­w©r'   Nr/   r5   s     r$   r%   z#_input_validator.<locals>.<genexpr>N   s   è ø€ ÐD¹e°dŒz˜$˜x™.¬&×1¹eùr6   z3Expected all labels in `preds` to be of type Tensorc              3   óD   •K  — | ]  }t        |‰   t        «      –— Œ y ­wr   r/   )r!   Útargetr2   s     €r$   r%   z#_input_validator.<locals>.<genexpr>Q   s   øè ø€ ÐIÁ°v”:˜f S™k¬6×2Áùr3   z! in `target` to be of type Tensorc              3   óB   K  — | ]  }t        |d    t        «      –— Œ y­wr8   r/   )r!   r:   s     r$   r%   z#_input_validator.<locals>.<genexpr>S   s   è ø€ ÐJÁ'¸Œz˜& Ñ*¬F×3Á'ùr6   z4Expected all labels in `target` to be of type Tensorr   zInput 'z' and labels of sample z. in targets have a different length (expected z labels, got Ú)Nz', labels and scores of sample z2 in predictions have a different length (expected z labels and scores, got z labels and )
r0   ÚstrÚanyÚ	Exceptionr   Ú
ValueErrorÚlenÚallÚ	enumerateÚsize)r   r   r   r   r"   Úitem_val_nameÚiÚitemr2   r,   r#   s           @@@r$   Ú_input_validatorrH   )   sr  ú€ ô �(œCÔ Ø�;ˆà¨Ñ1€HÜ
Ó
1©Ó
1Ô1Ü˜) H :Ð->Ð?Ó@Ð@Ù,4Ó5©H b�X˜b“\¨H€MÐ5ä�eœXÔ&ÜÐUÐV[ÐU\Ð]Ó^Ð^Ü�gœxÔ(ÜÐVÐW^ÐV_Ð`ÓaÐaÜ
ˆ5ƒz”S˜“\Ò!ÜØVÔWZÐ[`ÓWaÐVbÐbgÔhkÐlsÓhtÐguÐvó
ð 	
ð (ˆ}Ð'˜hÐ'¹\¨H©:ÈrÔRˆÜÓ)¡5Ó)Õ)ÜÐMÈaÈSÐPUÐVÓWÐWð Sð (ˆ}Ð'˜hÓ'ˆÜÓ+¡7Ó+Õ+ÜÐNÈqÈcÐQVÐWÓXÐXð (ó ˆÜÓC¹UÓCÕCÜ˜}¨S¨EÐ1QÐRÓSÐSð ñ ¤Ñ#YÑSXÓ#YÔ YÜÐNÓOÐOÜÑD¹eÓDÔDÜÐNÓOÐOÛˆÜÓIÁÓIÕIÜ˜}¨S¨EÐ1RÐSÓTÐTð ô ÑJÁ'ÓJÔJÜÐOÓPÐPä˜WÖ%‰ˆˆ4Û ˆCØ�C‰y�~‰~˜aÓ  D¨¡N×$7Ñ$7¸Ó$:Ó:Ü Ø˜c˜UÐ"9¸!¸ð =3Ø37¸±9·>±>À!Ó3DÐ2EÀ]ÐSWÐX`ÑSa×SfÑSfÐghÓSiÐRjÐjkðmóð ñ !ð &ñ ØÜ˜UÖ#‰ˆˆ4Û ˆCØ˜‘I—N‘N 1Ó%¨¨h©×)<Ñ)<¸QÓ)?ÔYÀ4ÈÁ>×CVÑCVÐWXÓCYÕYÜ Ø˜c˜UÐ"AÀ!Àð E3Ø37¸±9·>±>À!Ó3DÐ2Eð FØ  ™N×/Ñ/°Ó2Ð3°<ÀÀXÁ×@SÑ@SÐTUÓ@VÐ?WÐWXðZóð ñ !ñ $ùòS 6s   ÁL	r   c                 ól   — | j                  «       dk(  r | j                  dk(  r| j                  d«      S | S )zIEmpty tensors can cause problems in DDP mode, this methods corrects them.r   é   )ÚnumelÚndimÚ	unsqueeze)r   s    r$   Ú_fix_empty_tensorsrN   i   s.   € à‡{�{ƒ}˜Ò˜eŸj™j¨AšoØ�‰˜qÓ!Ð!Ø€Ló    c                 ó|   ‡— dŠt        | t        «      r| f} t        ˆfd„| D «       «      rt        d‰› d| › �«      ‚| S )z+Validate that iou type argument is correct.)r   r   c              3   ó&   •K  — | ]  }|‰v–— Œ
 y ­wr   r    )r!   r"   Úallowed_iou_typess     €r$   r%   z)_validate_iou_type_arg.<locals>.<genexpr>w   s   øè ø€ Ð
:±¨2ˆ2Ð&Ô&±ùr&   z*Expected argument `iou_type` to be one of z or a tuple of, but got )r0   r=   r>   r@   )r   rR   s    @r$   Ú_validate_iou_type_argrS   p   sS   ø€ ð )ÐÜ�(œCÔ Ø�;ˆÜ
Ó
:±Ó
:Ô:ÜØ8Ð9JÐ8KÐKcÐdlÐcmÐnó
ð 	
ð €OrO   Úbackend©ÚpycocotoolsÚfaster_coco_evalc                 ó¬   — | dk(  r(t         st        d«      ‚ddlm} ddlm} ddlm} |||fS t        st        d«      ‚ddl	m} ddl	m
} dd	lm} |||fS )
z-Load the backend tools for the given backend.rV   z¿Backend `pycocotools` in metric `MeanAveragePrecision`  metric requires that `pycocotools` is installed. Please install with `pip install pycocotools` or `pip install torchmetrics[detection]`r   N)ÚCOCO)ÚCOCOevalz¦Backend `faster_coco_eval` in metric `MeanAveragePrecision`  metric requires that `faster-coco-eval` is installed. Please install with `pip install faster-coco-eval`.)ÚCOCOeval_faster)Úmask)r   ÚModuleNotFoundErrorÚpycocotools.maskr\   Úpycocotools.cocorY   Úpycocotools.cocoevalrZ   r   rW   r[   Úfaster_coco_eval.core)rT   Ú
mask_utilsrY   rZ   s       r$   Ú_load_coco_backend_toolsrc   ~   sf   € à�-ÒÝ%Ü%ðuóð õ 	.Ý)Ý1à�X˜zÐ)Ð)å&Ü!ðNó
ð 	
õ &Ý<Ý8à�˜:Ð%Ð%rO   c                   ó  — e Zd ZdZded   ddfd„Zedefd„«       Zedefd„«       Z	edefd	„«       Z
	 	 d*d
ee   dee   dee   dee   dee   dee   dee   dee   dee   deed   eed   df   f   ded   deeef   fd„Zdee   dedee   deeef   fd„Ze	 	 d+dededeed   eed   df   f   ded   deeeeef      eeeef      f   f
d„«       Z	 	 	 d,d
ee   dee   dee   dee   dee   dee   dee   dee   dee   d edeed   eed   df   f   ded   ddfd!„Z	 	 	 	 	 	 	 d-d"ee   d#ee   d$eee      d%eee      d&eee      d'eee      d(eee      deed   eed   df   f   ded   defd)„Zy).ÚCocoBackendaI  Backend implementation for COCO-style Mean Average Precision (mAP) calculation.

    This class provides the core functionality for evaluating object detection and instance
    segmentation predictions using the Common Objects in Context (COCO) evaluation protocol.
    It supports both the standard 'pycocotools' and optimized 'faster_coco_eval' backends.

    It's used for calculation of mAP in MeanAveragePrecision class. It's a backend that abstracts
    away the mAP calculation with coco package

    Args:
        backend (str): Either 'pycocotools' or 'faster_coco_eval'

    rT   rU   r   Nc                 ó6   — |dvrt        d|› �«      ‚|| _        y )NrU   zUExpected argument `backend` to be one of ('pycocotools', 'faster_coco_eval') but got )r@   rT   )ÚselfrT   s     r$   Ú__init__zCocoBackend.__init__§   s-   € ØÐ=Ñ=ÜØgÐhoÐgpÐqóð ð ˆ�rO   c                 ó8   — t        | j                  «      \  }}}|S )z.Returns the coco module for the given backend.©rc   rT   )rg   ÚcocoÚ_s      r$   rk   zCocoBackend.coco®   s   € ô .¨d¯l©lÓ;‰
ˆˆa�ØˆrO   c                 ó8   — t        | j                  «      \  }}}|S )z3Returns the coco eval module for the given backend.rj   )rg   rl   Úcocoevals      r$   rn   zCocoBackend.cocoeval´   s   € ô 2°$·,±,Ó?‰ˆˆ8�QØˆrO   c                 ó8   — t        | j                  «      \  }}}|S )z4Returns the mask utils object for the given backend.rj   )rg   rl   rb   s      r$   rb   zCocoBackend.mask_utilsº   s   € ô 4°D·L±LÓAÑˆˆ1ˆjØÐrO   Úgroundtruth_labelsÚgroundtruth_boxÚgroundtruth_maskÚgroundtruth_crowdsÚgroundtruth_areaÚdetection_labelsÚdetection_boxÚdetection_maskÚdetection_scoresr   r   .Úaverage©ÚmacroÚmicroc           
      ó  — |dk(  r$t        |t        d„ «      }t        |t        d„ «      }| j                  «       | j                  «       }}t        |«      dkD  st        |«      dkD  rBt	        j
                  ||z   «      j                  «       j                  «       j                  «       ng }| j                  |t        |«      dkD  r|ndt        |«      dkD  r|nd|||
||¬«      |_
        | j                  |t        |«      dkD  r|ndt        |«      dkD  r|nd|	|
||¬«      |_
        t        j                  t        j                  «       «      5  |j                  «        |j                  «        ddd«       ||fS # 1 sw Y   ||fS xY w)z=Returns the coco datasets for the target and the predictions.r|   c                 ó,   — t        j                  | «      S r   ©ÚtorchÚ
zeros_like©Úxs    r$   Ú<lambda>z0CocoBackend._get_coco_datasets.<locals>.<lambda>Ñ   s   € Ô[`×[kÑ[kÐlmÔ[nrO   c                 ó,   — t        j                  | «      S r   r   r‚   s    r$   r„   z0CocoBackend._get_coco_datasets.<locals>.<lambda>Ò   s   € ÔW\×WgÑWgÐhiÔWjrO   r   N)r'   r   r   ÚcrowdsÚarear   Ú
all_labelsry   )r'   r   r   r(   r   rˆ   ry   )r   r   rk   rA   r€   ÚcatÚuniqueÚcpuÚtolistÚ_get_coco_formatÚdatasetÚ
contextlibÚredirect_stdoutÚioÚStringIOÚcreateIndex)rg   rp   rq   rr   rs   rt   ru   rv   rw   rx   r   ry   Úcoco_targetÚ
coco_predsrˆ   s                  r$   Ú_get_coco_datasetszCocoBackend._get_coco_datasetsÀ   s†  € ð �gÒä!4Ð5GÌÑQnÓ!oÐÜ2Ð3CÄVÑMjÓkÐà"&§)¡)£+¨t¯y©y«{�Zˆô
 Ð#Ó$ qÒ(¬CÐ0BÓ,CÀaÒ,Gô �I‰IÐ&Ð);Ñ;Ó<×CÑCÓE×IÑIÓK×RÑRÔTàð 	ð
 #×3Ñ3Ø%Ü%(¨Ó%9¸AÒ%=‘/À4Ü&)Ð*:Ó&;¸aÒ&?Ñ"ÀTØ%Ø!ØØ!Øð 4ó 	
ˆÔð "×2Ñ2Ø#Ü#& }Ó#5¸Ò#9‘-¸tÜ$'¨Ó$7¸!Ò$;‘.ÀØ#ØØ!Øð 3ó 
ˆ
Ôô ×'Ñ'¬¯©«Õ6Ø×#Ñ#Ô%Ø×"Ñ"Ô$÷ 7ð ˜;Ð&Ð&÷	 7ð ˜;Ð&Ð&ús   Å!E9Å9FÚstatsÚprefixÚmax_detection_thresholdsc                 óH  — |}|› d�t        j                  |d   gt         j                  ¬«      |› d�t        j                  |d   gt         j                  ¬«      |› d�t        j                  |d   gt         j                  ¬«      |› d�t        j                  |d	   gt         j                  ¬«      |› d
�t        j                  |d   gt         j                  ¬«      |› d�t        j                  |d   gt         j                  ¬«      |› d|d   › �t        j                  |d   gt         j                  ¬«      |› d|d   › �t        j                  |d   gt         j                  ¬«      |› d|d   › �t        j                  |d   gt         j                  ¬«      |› d�t        j                  |d   gt         j                  ¬«      |› d�t        j                  |d   gt         j                  ¬«      |› d�t        j                  |d   gt         j                  ¬«      iS )z;Converts the output of COCOeval.stats to a dict of tensors.Úmapr   ©ÚdtypeÚmap_50rJ   Úmap_75é   Ú	map_smallé   Ú
map_mediumé   Ú	map_largeé   Úmar_é   é   é   Ú	mar_smallé	   Ú
mar_mediumé
   Ú	mar_largeé   ©r€   ÚtensorÚfloat32)rg   r—   r˜   r™   Úmdts        r$   Ú_coco_stats_to_tensor_dictz&CocoBackend._coco_stats_to_tensor_dictö   s¶  € ð 'ˆàˆh�cˆNœEŸL™L¨%°©(¨¼5¿=¹=ÔIØˆh�fÐœuŸ|™|¨U°1©X¨J¼e¿m¹mÔLØˆh�fÐœuŸ|™|¨U°1©X¨J¼e¿m¹mÔLØˆh�iÐ ¤%§,¡,°°a±¨zÄÇÁÔ"OØˆh�jÐ!¤5§<¡<°°q±°
Ä%Ç-Á-Ô#PØˆh�iÐ ¤%§,¡,°°a±¨zÄÇÁÔ"OØˆh�d˜3˜q™6˜(Ð#¤U§\¡\°5¸±8°*ÄEÇMÁMÔ%RØˆh�d˜3˜q™6˜(Ð#¤U§\¡\°5¸±8°*ÄEÇMÁMÔ%RØˆh�d˜3˜q™6˜(Ð#¤U§\¡\°5¸±8°*ÄEÇMÁMÔ%RØˆh�iÐ ¤%§,¡,°°a±¨zÄÇÁÔ"OØˆh�jÐ!¤5§<¡<°°r±°Ä5Ç=Á=Ô#QØˆh�iÐ ¤%§,¡,°°b±	¨{Ä%Ç-Á-Ô"Pð
ð 	
rO   r•   r”   c                 óÐ  — t        |«      }t        |«      \  }}}t        j                  t	        j
                  «       «      5   ||«      }|j                  | «      }ddd«       j                  d   }j                  d   }	i }
|D ]Ø  }|d   |
vr*g g g dœ|
|d   <   d|v rg |
|d      d<   d|v rg |
|d      d<   d|v r|
|d      d   j                  |d   «       d|v r)|
|d      d   j                  |j                  |«      «       |
|d      d	   j                  |d
   «       |
|d      d   j                  |d   «       |
|d      d   j                  |d   «       ŒÚ i }|	D ]º  }|d   |vr)g g dœ||d   <   d|v rg ||d      d<   d|v rg ||d      d<   d|v r||d      d   j                  |d   «       d|v r)||d      d   j                  |j                  |«      «       ||d      d   j                  |d   «       ||d      d	   j                  |d
   «       Œ¼ |
D ](  }||vsŒg g dœ||<   d|v rg ||   d<   d|v sŒ!g ||   d<   Œ* g g }}|
D �]þ  }t        j                  ||   d   t        j                  ¬«      t        j                  ||   d	   t        j                  ¬«      dœ}d|v rAt        j                  t        j                  ||   d   «      t        j                  ¬«      |d<   d|v rAt        j                  t        j                  ||   d   «      t        j                   ¬«      |d<   |j                  |«       t        j                  |
|   d	   t        j                  ¬«      t        j                  |
|   d   t        j                  ¬«      t        j                  |
|   d   t        j                  ¬«      dœ}d|v r.t        j                  |
|   d   t        j                  ¬«      |d<   d|v rAt        j                  t        j                  |
|   d   «      t        j                   ¬«      |d<   |j                  |«       �Œ ||fS # 1 sw Y   �ŒxY w)aÏ  Utility function for converting .json coco format files to the input format of the mAP metric.

        The function accepts a file for the predictions and a file for the target in coco format and converts them to
        a list of dictionaries containing the boxes, labels and scores in the input format of mAP metric.

        Args:
            coco_preds: Path to the json file containing the predictions in coco format
            coco_target: Path to the json file containing the targets in coco format
            iou_type: Type of input, either `bbox` for bounding boxes or `segm` for segmentation masks
            backend: Backend to use for the conversion. Either `pycocotools` or `faster_coco_eval`.

        Returns:
            A tuple containing the predictions and targets in the input format of mAP metric. Each element of the
            tuple is a list of dictionaries containing the boxes, labels and scores.

        Example:
            >>> # File formats are defined at https://cocodataset.org/#format-data
            >>> # Example files can be found at
            >>> # https://github.com/cocodataset/cocoapi/tree/master/results
            >>> from torchmetrics.detection import MeanAveragePrecision
            >>> preds, target = MeanAveragePrecision().coco_to_tm(
            ...   "instances_val2014_fakebbox100_results.json",
            ...   "val2014_fake_eval_res.txt.json"
            ...   iou_type="bbox"
            ... )  # doctest: +SKIP

        NÚannotationsÚimage_id)r'   Úiscrowdr‡   r   r   r   r   r'   Úcategory_idr¹   r‡   )r(   r'   r(   Úscorerœ   )rS   rc   r�   r�   r‘   r’   ÚloadResrŽ   ÚappendÚ	annToMaskr€   r²   r³   Úint32ÚnpÚarrayÚuint8)r•   r”   r   rT   rk   rl   ÚgtÚdtÚ
gt_datasetÚ
dt_datasetr:   Útr   r+   r,   Úbatched_predsÚbatched_targetÚkeyÚbpÚbts                       r$   Ú
coco_to_tmzCocoBackend.coco_to_tm
  s‚  € ôD *¨(Ó3ˆÜ-¨gÓ6‰
ˆˆa�ä×'Ñ'¬¯©«Õ6Ù�kÓ"ˆBØ—‘˜JÓ'ˆB÷ 7ð —Z‘Z Ñ.ˆ
Ø—Z‘Z Ñ.ˆ
àˆÛˆAØ�‰} FÑ*à Ø!Øñ)��q˜‘}Ñ%ð
 ˜XÑ%Ø57�F˜1˜Z™=Ñ)¨'Ñ2Ø˜XÑ%Ø57�F˜1˜Z™=Ñ)¨'Ñ2à˜Ñ!Ø�q˜‘}Ñ% gÑ.×5Ñ5°a¸±iÔ@Ø˜Ñ!Ø�q˜‘}Ñ% gÑ.×5Ñ5°b·l±lÀ1³oÔFØ�1�Z‘=Ñ! (Ñ+×2Ñ2°1°]Ñ3CÔDØ�1�Z‘=Ñ! )Ñ,×3Ñ3°A°i±LÔAØ�1�Z‘=Ñ! &Ñ)×0Ñ0°°6±Õ;ð% ð( ˆÛˆAØ�‰} EÑ)Ø24ÀÑ'C��a˜
‘mÑ$Ø˜XÑ%Ø46�E˜!˜J™-Ñ(¨Ñ1Ø˜XÑ%Ø46�E˜!˜J™-Ñ(¨Ñ1Ø˜Ñ!Ø�a˜
‘mÑ$ WÑ-×4Ñ4°Q°v±YÔ?Ø˜Ñ!Ø�a˜
‘mÑ$ WÑ-×4Ñ4°R·\±\À!³_ÔEØ�!�J‘-Ñ  Ñ*×1Ñ1°!°G±*Ô=Ø�!�J‘-Ñ  Ñ*×1Ñ1°!°MÑ2BÕCð ó ˆAØ˜Š~Ø&(°BÑ7��a‘Ø˜XÑ%Ø(*�E˜!‘H˜WÑ%Ø˜XÒ%Ø(*�E˜!‘H˜WÒ%ð ð )+¨B�~ˆÜˆCäŸ,™, u¨S¡z°(Ñ';Ä5Ç=Á=ÔQÜŸ,™, u¨S¡z°(Ñ';Ä5Ç;Á;ÔOñˆBð ˜Ñ!Ü#Ÿl™l¬2¯8©8°E¸#±J¸wÑ4GÓ+HÔPU×P]ÑP]Ô^��7‘Ø˜Ñ!Ü#Ÿl™l¬2¯8©8°E¸#±J¸wÑ4GÓ+HÔPU×P[ÑP[Ô\��7‘Ø× Ñ  Ô$ô  Ÿ,™, v¨c¡{°8Ñ'<ÄEÇKÁKÔPÜ Ÿ<™<¨¨s©°IÑ(>ÄeÇkÁkÔRÜŸ™ V¨C¡[°Ñ%8ÄÇÁÔNñˆBð
 ˜Ñ!Ü#Ÿl™l¨6°#©;°wÑ+?ÄuÇ}Á}ÔU��7‘Ø˜Ñ!Ü#Ÿl™l¬2¯8©8°F¸3±KÀÑ4HÓ+IÔQV×Q\ÑQ\Ô]��7‘Ø×!Ñ! "Ö%ð) ð, ˜nÐ,Ð,÷S 7Ñ6ús   ÁQÑQ%Únamec           
      óü  — t        |«      dkD  st        |«      dkD  rBt        j                  ||z   «      j                  «       j	                  «       j                  «       ng }| j                  |t        |«      dkD  r|ndt        |«      dkD  r|nd|||||¬«      }| j                  |t        |«      dkD  r|ndt        |«      dkD  r|nd|	|||¬«      }d|v rŒt        |d   t        d„ ¬«      |d<   t        |d   t        j                  t        j                  fd	„ ¬«      |d<   t        |t        d
„ ¬«      }t        |t        j                  t        j                  fd„ ¬«      }t        j                  |d   d¬«      }t        j                  |d¬«      }t        |
› d�d«      5 }|j                  |«       ddd«       t        |
› d�d«      5 }|j                  |«       ddd«       y# 1 sw Y   Œ3xY w# 1 sw Y   yxY w)aÁ  Utility function for converting the input for mAP metric to coco format and saving it to a json file.

        This function should be used after calling `.update(...)` or `.forward(...)` on all data that should be written
        to the file, as the input is then internally cached. The function then converts to information to coco format
        and writes it to json files.

        Args:
            groundtruth_labels: List of tensors containing the ground truth labels
            groundtruth_box: List of tensors containing the ground truth bounding boxes
            groundtruth_mask: List of tensors containing the ground truth segmentation masks
            groundtruth_crowds: List of tensors indicating whether ground truth annotations are crowd annotations
            groundtruth_area: List of tensors containing the area of ground truth annotations
            detection_labels: List of tensors containing the predicted labels
            detection_box: List of tensors containing the predicted bounding boxes
            detection_mask: List of tensors containing the predicted segmentation masks
            detection_scores: List of tensors containing the confidence scores for predictions
            name: Name of the output file, which will be appended with "_preds.json" and "_target.json"
            iou_type: Type of IoU calculation to use. Can be either "bbox" for bounding box or "segm" for segmentation
            average: Type of averaging to use. Can be either "macro" or "micro"

        Example:
            >>> from torch import tensor
            >>> from torchmetrics.detection import MeanAveragePrecision
            >>> preds = [
            ...   dict(
            ...     boxes=tensor([[258.0, 41.0, 606.0, 285.0]]),
            ...     scores=tensor([0.536]),
            ...     labels=tensor([0]),
            ...   )
            ... ]
            >>> target = [
            ...   dict(
            ...     boxes=tensor([[214.0, 41.0, 562.0, 285.0]]),
            ...     labels=tensor([0]),
            ...   )
            ... ]
            >>> metric = MeanAveragePrecision(iou_type="bbox")
            >>> metric.update(preds, target)
            >>> metric.tm_to_coco("tm_map_input")

        r   N)r'   r   r   r†   r‡   rˆ   r   ry   )r'   r   r   r(   rˆ   r   ry   r   r·   c                 ó$   — | j                  d«      S ©Nzutf-8©Údecoder‚   s    r$   r„   z(CocoBackend.tm_to_coco.<locals>.<lambda>Í  s   € ÈaÏhÉhÐW^ÔN_rO   )r�   Úfunctionc                 ó   — t        | «      S r   ©Úintr‚   s    r$   r„   z(CocoBackend.tm_to_coco.<locals>.<lambda>Ò  s   € ¤3 q¤6rO   c                 ó$   — | j                  d«      S rÑ   rÒ   r‚   s    r$   r„   z(CocoBackend.tm_to_coco.<locals>.<lambda>Ô  s   € Ðab×aiÑaiÐjqÔarrO   c                 ó   — t        | «      S r   rÖ   r‚   s    r$   r„   z(CocoBackend.tm_to_coco.<locals>.<lambda>Ö  s   € ÔQTÐUVÔQWrO   r¤   )Úindentz_preds.jsonÚwz_target.json)rA   r€   r‰   rŠ   r‹   rŒ   r�   r   ÚbytesrÀ   Úuint32Úuint64ÚjsonÚdumpsÚopenÚwrite)rg   rp   rq   rr   rs   rt   ru   rv   rw   rx   rÎ   r   ry   rˆ   Útarget_datasetÚpreds_datasetÚ
preds_jsonÚtarget_jsonÚfs                      r$   Ú
tm_to_cocozCocoBackend.tm_to_cocoz  sõ  € ôt Ð#Ó$ qÒ(¬CÐ0BÓ,CÀaÒ,Gô �I‰IÐ&Ð);Ñ;Ó<×CÑCÓE×IÑIÓK×RÑRÔTàð 	ð
 ×.Ñ.Ø%Ü%(¨Ó%9¸AÒ%=‘/À4Ü&)Ð*:Ó&;¸aÒ&?Ñ"ÀTØ%Ø!Ø!ØØð /ó 	
ˆð ×-Ñ-Ø#Ü#& }Ó#5¸Ò#9‘-¸tÜ$'¨Ó$7¸!Ò$;‘.ÀØ#Ø!ØØð .ó 
ˆð �XÑä+>Ø˜mÑ,´EÑD_ô,ˆM˜-Ñ(ô ,?Ø˜mÑ,Ü—y‘y¤"§)¡)Ð,Ù)ô,ˆM˜-Ñ(ô
 1°ÄuÑWrÔsˆNÜ0Ø¤r§y¡y´"·)±)Ð&<ÑGWôˆNô —Z‘Z ¨mÑ <ÀQÔGˆ
Ü—j‘j ¸Ô:ˆä�T�F˜+Ð&¨Ô,°Ø�G‰G�JÔ÷ -ô �T�F˜,Ð'¨Ô-°Ø�G‰G�KÔ ÷ .Ð-÷ -Ð,ú÷ .Ð-ús   Æ"G&ÇG2Ç&G/Ç2G;r'   rˆ   r   r   r(   r†   r‡   c
                 ó  — g }
g }d}t        |«      D �]ª  \  }}|�#||   }|j                  «       j                  «       }|�||   }t        |«      dk(  r|€ŒD|j                  «       j                  «       }|
j	                  d|i«       d|v r1t        «      dkD  r#|d   d   d   |d   d   d   c|
d   d<   |
d   d<   t        |«      D �]ò  \  }}|�|   }|�t        «      dkD  r||   }|d   |d   d	œ}d
|v r,t        «      dk7  rt        d|› d|› dt        |«      › d�«      ‚t        |t        «      st        d|› d|› dt        |«      › d�«      ‚d}d}|�L||   |   j                  «       j                  «       dkD  r%||   |   j                  «       j                  «       }n^d|v r| j                  j                  «      n
d   |d   z  }t        |«      dkD  r&d   |d   z  }| j                  j                  «      }|||||�$||   |   j                  «       j                  «       nddœ}|�
||d<   ||d<   |�|d
<   |�|d<   |�W||   |   j                  «       j                  «       }t        |t        «      st        d|› d|› dt        |«      › d�«      ‚||d<   |j	                  |«       |dz  }�Œõ �Œ­ |	dk7  r|D �cg c]  }|t        |«      dœ‘Œ c}ndddœg}|
||dœ}t        rdd t        d!«      › �i|d"<   |S c c}w )#z�Transforms and returns all cached targets or predictions in COCO format.

        Format is defined at
        https://cocodataset.org/#format-data

        rJ   Nr   Úidr   éÿÿÿÿÚheightÚwidth)rD   Úcountsr   r¤   zInvalid input box of sample z
, element z (expected 4 values, got r<   zInvalid input class of sample z+ (expected value of type integer, got type r    r¢   )rê   r¸   r‡   rº   r¹   Ú	area_bboxÚ	area_segmÚsegmentationzInvalid input score of sample z) (expected value of type float, got type r»   r|   )rê   rÎ   Ú0)Úimagesr·   Ú
categoriesÚdescriptionz:Dummy info generated by tm_to_coco to support pycocotools rV   Úinfo)rC   r‹   rŒ   rA   r½   r@   r0   r×   Útyperb   r‡   Úfloatr=   r   r   )rg   r'   rˆ   r   r   r(   r†   r‡   r   ry   ró   r·   Úannotation_idr¸   Úimage_labelsÚimage_boxesÚimage_masksr,   Úimage_labelÚ	image_boxÚ
image_maskÚarea_stat_boxÚarea_stat_maskÚ	area_statÚ
annotationr»   rF   ÚclassesÚresults                                r$   r�   zCocoBackend._get_coco_formatâ  sâ  € ð$ ˆØˆØˆä&/°×&7Ñ"ˆH�lØÐ Ø# H™o�Ø)Ÿo™oÓ/×6Ñ6Ó8�ØÐ Ø# H™o�Ü�{Ó# qÒ(¨U¨]ØØ'×+Ñ+Ó-×4Ñ4Ó6ˆLà�M‰M˜4 Ð*Ô+Ø˜Ñ!¤c¨+Ó&6¸Ò&:Ø<GÈ¹NÈ1Ñ<MÈaÑ<PÐR]Ð^_ÑR`ÐabÑRcÐdeÑRfÐ9��r‘
˜8Ñ$ f¨R¡j°Ñ&9ä"+¨L×"9‘��;ØÐ$Ø +¨A¡�IØÐ$¬¨[Ó)9¸AÒ)=Ø!,¨Q¡�JØ*4°Q©-À:ÈaÁ=Ñ!Q�Jà˜XÑ%¬#¨i«.¸AÒ*=Ü$Ø6°x°jÀ
È1È#ÐMfÔgjÐktÓguÐfvÐvwÐxóð ô " +¬sÔ3Ü$Ø8¸¸
À*ÈQÈCØEÄdÈ;ÓFWÐEXÐXYð[óð ð
 !%�Ø!%�ØÐ#¨¨X©°qÑ(9×(=Ñ(=Ó(?×(FÑ(FÓ(HÈ1Ò(LØ $ X¡¨qÑ 1× 5Ñ 5Ó 7× >Ñ >Ó @‘IàDJÈhÑDV §¡× 4Ñ 4°ZÔ @Ð\eÐfgÑ\hÐktÐuvÑkwÑ\w�IÜ˜8“} qÒ(Ø(1°!©°yÀ±|Ñ(C˜Ø)-¯©×)=Ñ)=¸jÓ)I˜ð (Ø (Ø%Ø#.ØEKÐEW˜v hÑ/°Ñ2×6Ñ6Ó8×?Ñ?ÔAÐ]^ñ�
ð !Ð,Ø.;�J˜{Ñ+Ø.<�J˜{Ñ+àÐ$Ø)2�J˜vÑ&ØÐ$Ø1;�J˜~Ñ.àÐ%Ø" 8Ñ,¨QÑ/×3Ñ3Ó5×<Ñ<Ó>�EÜ% e¬UÔ3Ü(Ø<¸X¸JÀjÐQRÐPSØGÌÈUËÀ}ÐTUðWóð ð +0�J˜wÑ'Ø×"Ñ" :Ô.Ø Ñ"’òk #:ð '8ðJ FMÐPWÒEW±jÓA±j°˜!¤S¨£VÓ,°jÒAÐefÐpsÑ^tÐ]uˆàØ&Ø!ñ
ˆõ
 ,àÐ![Ô\cÐdqÓ\rÐ[sÐtðˆF�6‰Nð ˆùò Bs   Ë	L)©r   r|   )r  rV   )Útm_map_inputr  r|   )NNNNNr  r|   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   rh   ÚpropertyÚobjectrk   rn   rb   r   r   r   Útupler–   Úlistrø   r=   r×   Údictrµ   ÚstaticmethodrÍ   rè   r
   r�   r    rO   r$   re   re   ˜   sé  „ ñð Ð(IÑ Jð Ètó ð ð�fò ó ðð
 ð˜&ò ó ðð
 ð˜Fò ó ðð  YbØ-4ñ4'à  ™Lð4'ð ˜f™ð4'ð ˜v™,ð	4'ð
 ! ™Lð4'ð ˜v™,ð4'ð ˜v™,ð4'ð ˜F‘|ð4'ð ˜V™ð4'ð ˜v™,ð4'ð ˜ Ñ/°°w¸~Ñ7NÐPSÐ7SÑ1TÐTÑUð4'ð Ð)Ñ*ð4'ð 
ˆv�vˆ~Ñ	ó4'ðl
Ø˜%‘[ð
Ø*-ð
ØIMÈcÉð
à	ˆc�6ˆkÑ	ó
ð( ð YbØ>Kñ	m-Øðm-àðm-ð ˜ Ñ/°°w¸~Ñ7NÐPSÐ7SÑ1TÐTÑUðm-ð Ð:Ñ;ð	m-ð
 
ˆt�D˜˜f˜Ñ%Ñ&¨¨T°#°v°+Ñ->Ñ(?Ð?Ñ	@òm-ó ðm-ðt #ØXaØ-4ñf!à  ™Lðf!ð ˜f™ðf!ð ˜v™,ð	f!ð
 ! ™Lðf!ð ˜v™,ðf!ð ˜v™,ðf!ð ˜F‘|ðf!ð ˜V™ðf!ð ˜v™,ðf!ð ðf!ð ˜ Ñ/°°w¸~Ñ7NÐPSÐ7SÑ1TÐTÑUðf!ð Ð)Ñ*ðf!ð 
óf!ðX )-Ø(,Ø)-Ø)-Ø'+ØXaØ-4ñeà�V‘ðeð ˜‘Lðeð ˜˜V™Ñ%ð	eð
 ˜˜V™Ñ%ðeð ˜˜f™Ñ&ðeð ˜˜f™Ñ&ðeð �t˜F‘|Ñ$ðeð ˜ Ñ/°°w¸~Ñ7NÐPSÐ7SÑ1TÐTÑUðeð Ð)Ñ*ðeð 
ôerO   re   Úlimitc                 ó,   — t        d| › d�t        «       y )NzEncountered more than aY   detections in a single image. This means that certain detections with the lowest scores will be ignored, that may have an undesirable impact on performance. Please consider adjusting the `max_detection_threshold` to suit your use case. To disable this warning, set attribute class `warn_on_many_detections=False`, after initializing the metric.)r   ÚUserWarning)r  s    r$   Ú_warning_on_too_many_detectionsr  J  s"   € ÜØ
   ð (Kð 	Kô 	õrO   Ú
box_formatr™   Úcoco_backendrG   Úwarnc                 ó  ‡‡— ddl m} ddgŠd| v r1t        |d   «      }|j                  «       dkD  r |||d¬«      }|‰d<   d| v r†g }|d	   j	                  «       j                  «       D ]R  }	|j                  j                  t        j                  |	«      «      }
|j                  t        |
d
   «      |
d   f«       ŒT t        |«      ‰d<   dt        dt        fˆˆfd„}|r |d«      s |d«      rt        ‰d   «       ‰S )a.  Convert and return the boxes or masks from the item depending on the iou_type.

    Args:
        iou_type:
            Type of input to process. Supported types are:
                - "bbox": Process bounding boxes
                - "segm": Process segmentation masks
        box_format:
            Input format of given boxes. Supported formats are:
                - 'xyxy': boxes are represented via corners, x1, y1 being top left and x2, y2 being bottom right.
                - 'xywh': boxes are represented via corner, width and height, x1, y2 being top left, w, h being
                  width and height.
                - 'cxcywh': boxes are represented via centre, width and height, cx, cy being center of box, w, h being
                  width and height.
        max_detection_thresholds:
            List of thresholds on maximum detections per image. Used to determine if warnings should be raised
            when the number of detections exceeds these thresholds.
        coco_backend:
            The COCO evaluation backend class type to use for processing the items.
        item:
            Input dictionary containing the boxes or masks to be processed, along with other detection information.
        warn:
            Whether to warn if the number of boxes or masks exceeds the max_detection_thresholds.
            Default is False.

    Returns:
        A tuple containing processed boxes or masks depending on the iou_type. The first element is the
        tensor representation, and the second element contains additional metadata if applicable.

    r   )Úbox_convertNr   r   Úxywh)Úin_fmtÚout_fmtr   r   rD   rî   rJ   Úidxr   c                 ó6   •— ‰|    }|€yt        |«      ‰d   kD  S )NFrë   )rA   )r  Úvalr™   Úoutputs     €€r$   Ú_valid_output_lenz0_get_safe_item_values.<locals>._valid_output_len‰  s)   ø€ Ø�S‰kˆØˆ;ØÜ�3‹xÐ2°2Ñ6Ñ6Ð6rO   rë   )Útorchvision.opsr  rN   rK   r‹   Únumpyrb   ÚencoderÀ   Úasfortranarrayr½   r  r×   Úboolr  )r   r  r™   r  rG   r  r  r   r   rF   Úrler"  r!  s     `         @r$   Ú_get_safe_item_valuesr)  T  s  ù€ õL ,à�Dˆ\€FØ�ÑÜ" 4¨¡=Ó1ˆØ�;‰;‹=˜1ÒÙ ¨jÀ&ÔIˆEØˆˆq‰	Ø�ÑØˆØ�g‘×"Ñ"Ó$×*Ñ*Ö,ˆAØ×)Ñ)×0Ñ0´×1BÑ1BÀ1Ó1EÓFˆCØ�L‰Lœ%  F¡Ó,¨c°(©mÐ<Õ=ð -ô ˜%“Lˆˆq‰	ð7œsð 7¤tö 7ñ Ñ" 1Ô%Ñ):¸1Ô)=Ü'Ð(@ÀÑ(DÔEØ€MrO   ru   rp   c                 óÂ   — t        | «      dkD  st        |«      dkD  rBt        j                  | |z   «      j                  «       j	                  «       j                  «       S g S )Nr   )rA   r€   r‰   rŠ   r‹   rŒ   ©ru   rp   s     r$   Ú_get_classesr,  ”  sS   € Ü
ÐÓ˜qÒ ¤CÐ(:Ó$;¸aÒ$?Ü�y‰yÐ)Ð,>Ñ>Ó?×FÑFÓH×LÑLÓN×UÑUÓWÐWØ€IrO   rq   rr   rs   rt   rv   rw   rx   ry   rz   Úiou_thresholdsÚrec_thresholdsÚclass_metricsÚextended_summaryc                 óš
  — | j                  |||||||||	|
|¬«      \  }}i }t        j                  t        j                  «       «      5  |
D �]˜  }t        |
«      dk(  rdn|› d�}t        |
«      dkD  r|j                  d   D ]  }|d|› �   |d<   Œ t        |j                  «      dk(  st        |j                  «      dk(  r(|j                  | j                  d	d
gz  ||¬«      «       Œž| j                  |||¬«      }t        j                  |t        j                  ¬«      |j                  _        t        j                  |t        j                  ¬«      |j                  _        ||j                  _        |j%                  «        |j'                  «        |j)                  «        |j*                  }|j                  | j                  |||¬«      «       i }|rš|› d�t-        |j.                  t        j0                  d„ «      |› d�t3        j4                  |j6                  d   «      |› d�t3        j4                  |j6                  d   «      |› d�t3        j4                  |j6                  d   «      i}|j                  |«       |�rÛ| j                  |||||||||	|
d¬«      \  }}| j                  |||¬«      }t        j                  |t        j                  ¬«      |j                  _        t        j                  |t        j                  ¬«      |j                  _        ||j                  _        g }g }t9        ||¬«      D ]Ð  }|g|j                  _        t        j                  t        j                  «       «      5  |j%                  «        |j'                  «        |j)                  «        |j*                  }d d d «       |j=                  t3        j4                  d   g«      «       |j=                  t3        j4                  |d   g«      «       ŒÒ t3        j4                  |t2        j>                  ¬«      }t3        j4                  |t2        j>                  ¬«      }nLt3        j4                  dgt2        j>                  ¬«      }t3        j4                  dgt2        j>                  ¬«      }t        |
«      dk(  rdn|› d�}|j                  |› d�||› d|d   › d�|i«       �Œ› 	 d d d «       |j                  dt3        j4                  t9        ||¬«      t2        j@                  ¬«      i«       |S # 1 sw Y   �ŒxxY w# 1 sw Y   ŒYxY w)N)ry   rJ   Ú rl   r·   Úarea_r‡   r   é   g      ð¿)r˜   r™   )ÚiouTyperœ   Úiousc                 óL   — t        j                  | t         j                  ¬«      S )Nrœ   r±   r‚   s    r$   r„   z*_calculate_map_with_coco.<locals>.<lambda>ß  s   € Ä%Ç,Á,ÈqÔX]×XeÑXeÕBfrO   Ú	precisionÚrecallr(   r{   r+  rª   rë   Úmap_per_classr§   Ú
_per_classr  )!r–   r�   r�   r‘   r’   rA   rŽ   ÚimgsÚupdaterµ   rn   rÀ   rÁ   Úfloat64ÚparamsÚiouThrsÚrecThrsÚmaxDetsÚevaluateÚ
accumulateÚ	summarizer—   r   r6  Úndarrayr€   r²   Úevalr,  ÚcatIdsr½   r³   r¿   ) r  rp   rq   rr   rs   rt   ru   rv   rw   rx   r   ry   r-  r.  r™   r/  r0  r•   r”   Úresult_dictÚi_typer˜   ÚannoÚ	coco_evalr—   ÚsummaryÚmap_per_class_listÚmar_per_class_listÚclass_idÚclass_statsÚmap_per_class_valuesÚmar_per_class_valuess                                    r$   Ú_calculate_map_with_cocorT  š  sÊ  € ð& +×=Ñ=ØØØØØØØØØØØð >ó Ñ€J�ð €KÜ	×	#Ñ	#¤B§K¡K£MÕ	2ÜˆFÜ˜x›=¨AÒ-‘R°f°X¸Q°<ˆFÜ�8‹}˜qÒ ð '×.Ñ.¨}Ô=�DØ#'¨%°¨xÐ(8Ñ#9�D˜’Lð >ô �:—?‘?Ó# qÒ(¬C°×0@Ñ0@Ó,AÀQÒ,FØ×"Ñ"Ø ×;Ñ;Ø˜d˜V™¨FÐMeð <ó õð )×1Ñ1°+¸zÐSYÐ1ÓZ�	Ü+-¯8©8°NÌ"Ï*É*Ô+U�	× Ñ Ô(Ü+-¯8©8°NÌ"Ï*É*Ô+U�	× Ñ Ô(Ø+C�	× Ñ Ô(à×"Ñ"Ô$Ø×$Ñ$Ô&Ø×#Ñ#Ô%Ø!Ÿ™�Ø×"Ñ"Ø ×;Ñ;Ø fÐG_ð <ó ôð �Ù#à!˜( $˜Ô)<Ø%ŸN™N¬B¯J©JÑ8fó*ð "˜( )Ð,¬e¯l©l¸9¿>¹>È+Ñ;VÓ.WØ!˜( &Ð)¬5¯<©<¸	¿¹ÀxÑ8PÓ+QØ!˜( &Ð)¬5¯<©<¸	¿¹ÀxÑ8PÓ+Qð�Gð ×"Ñ" 7Ô+ò !ð /;×.MÑ.MØ*Ø'Ø(Ø*Ø(Ø(Ø%Ø&Ø(Ø Ø 'ð /Nó /Ñ+�J ð !-× 5Ñ 5°kÀ:ÐW]Ð 5Ó ^�IÜ/1¯x©x¸ÌbÏjÉjÔ/Y�I×$Ñ$Ô,Ü/1¯x©x¸ÌbÏjÉjÔ/Y�I×$Ñ$Ô,Ø/G�I×$Ñ$Ô,à)+Ð&Ø)+Ð&Ü$0Ø)9ÐN`÷%˜ð 4<°*˜	×(Ñ(Ô/Ü'×7Ñ7¼¿¹»ÕFØ%×.Ñ.Ô0Ø%×0Ñ0Ô2Ø%×/Ñ/Ô1Ø*3¯/©/˜K÷	 Gð +×1Ñ1´%·,±,ÀÈAÁÐ?OÓ2PÔQØ*×1Ñ1´%·,±,ÀÈAÁÐ?OÓ2PÕQð%ô ,1¯<©<Ð8JÔRW×R_ÑR_Ô+`Ð(Ü+0¯<©<Ð8JÔRW×R_ÑR_Ô+`Ñ(ä+0¯<©<¸¸ÄEÇMÁMÔ+RÐ(Ü+0¯<©<¸¸ÄEÇMÁMÔ+RÐ(Ü" 8›}°Ò1™¸&¸À°|�Ø×"Ñ"à!˜( -Ð0Ð2FØ!˜( $Ð'?ÀÑ'CÐ&DÀJÐOÐQeðöñk ÷ 
3ðx ×ÑØ”5—<‘<ÜÐ*:ÐOaÔbÔjo×juÑjuô
ðô ð
 Ð÷5 GÑFú÷O 
3Ð	2ús&   Á	L8UÎ=T4	Î>D*UÔ4T>Ô9UÕU
)r   Fr  )F).r�   r‘   rß   Úcollections.abcr   Úimportlib.metadatar   Útypesr   Útypingr   r   r   r	   r
   r   r   r$  rÀ   r€   Úlightning_utilitiesr   r   Útorchmetrics.utilitiesr   Útorchmetrics.utilities.importsr   r   r   Ú__doctest_skip__r  r=   r  r'  rH   rN   rS   r  rc   re   r×   r  r)  r,  rø   rT  r    rO   r$   Ú<module>r]     sF  ðó Û 	Û Ý $Ý &Ý ß C× CÑ Cã Û Ý 3Ý å 1÷ñ ñ 	Ñ"=à Ø ðÐð U[Øñ	=Ø�D˜˜f˜Ñ%Ñ&ð=à�d˜3 ˜;Ñ'Ñ(ð=ð �G˜NÑ+¨U°7¸>Ñ3JÈCÐ3OÑ-PÐPÑQð=ð ð	=ð
 
ó=ð@˜fð ¨ó ð U[ñØ�G˜NÑ+¨U°7¸>Ñ3JÈCÐ3OÑ-PÐPÑQðà
ˆ7�>Ñ" CÐ'Ñ(óð& gÐ.OÑ&Pð &ÐUZÐ[aÐciÐkuÐ[uÑUvó &÷4oñ oðd¨3ð °4ó ð  ñ=Ø�G˜NÑ+¨U°7¸>Ñ3JÈCÐ3OÑ-PÐPÑQð=àð=ð # 3™ið=ð ð	=ð
 ˆs�Cˆx‰.ð=ð ð=ð ˆ8�FÑ˜X e™_Ð,Ñ-ó=ð@ 4¨¡<ð ÀTÈ&Á\ð ÐVZÐ[^ÑV_ó ðCØðCà˜V™ðCð ˜&‘\ðCð ˜6‘lð	Cð
 ˜V™ðCð ˜6‘lðCð ˜6‘lðCð ˜‘<ðCð ˜‘LðCð ˜6‘lðCð �G˜NÑ+¨U°7¸>Ñ3JÈCÐ3OÑ-PÐPÑQðCð Ð%Ñ&ðCð ˜‘KðCð ˜‘KðCð # 3™iðCð  ð!Cð" ð#Cð$ 
ˆ#ˆvˆ+Ñô%CrO   