§
    ­¸j¾  ã                  ó2   — d Z ddlmZ ddlZddlmZ dd„ZdS )z=Class-layout handling shared by the export inference helpers.é    )ÚannotationsN)ÚNDArrayÚ
scores_allúNDArray[np.floating]Úbackground_class_idú
int | NoneÚreturnú.tuple[NDArray[np.floating], NDArray[np.int64]]c                óì  — | j         dk    rt          d| j        › �¦  «        ‚| j        d         }t          j        |t          j        ¬¦  «        }|€| |fS t          |t          ¦  «        s!t          |t          t          j	        f¦  «        s(t          d|›dt          |¦  «        j        › d�¦  «        ‚| |cxk    r|k     sn t          d	|› d
|› �¦  «        ‚|||z  k    }| dd…|f         ||         fS )aÁ  Exclude one background slot while retaining the original exported class IDs.

    Args:
        scores_all: Per-query, per-class scores with shape ``(Q, C)``.
        background_class_id: Exported class slot to exclude. Negative indices follow NumPy conventions; ``None`` keeps
            every slot.

    Returns:
        The score grid to rank and its corresponding original exported class IDs.

    Raises:
        ValueError: If *scores_all* is not rank-2 or *background_class_id* is out of range.
        TypeError: If *background_class_id* is neither ``None`` nor an ``int`` (``bool`` is rejected too, since it is
            an ``int`` subclass and would otherwise silently act as index 0/1).
    é   z'scores_all must have shape (Q, C); got é   )ÚdtypeNz0background_class_id must be an int or None; got z (ú)z&background_class_id must index one of z exported class slots; got )ÚndimÚ
ValueErrorÚshapeÚnpÚarangeÚint64Ú
isinstanceÚboolÚintÚintegerÚ	TypeErrorÚtypeÚ__name__)r   r   Únum_classesÚ	class_idsÚforeground_masks        úk/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/rfdetr/export/_class_layout.pyÚ_exclude_background_classr!      sJ  € ð& „˜!ÒÐÝÐUÀ:ÔCSÐUÐUÑVÔVÐVàÔ" 1Ô%€KÝ”	˜+­R¬XÐ6Ñ6Ô6€IØÐ"Ø˜9Ð$Ð$ÝÐ%¥tÑ,Ô,ð 
µJÐ?RÕUXÕZ\ÔZdÐTeÑ4fÔ4fð 
Ýð6Ð?Rð 6ð 6ÝÐ(Ñ)Ô)Ô2ð6ð 6ð 6ñ
ô 
ð 	
ð ˆ<Ð.Ð<Ð<Ò<Ð<°Ò<Ð<Ð<Ð<ÝØr°[ÐrÐrÐ]pÐrÐrñ
ô 
ð 	
ð  Ð#6¸Ñ#DÒD€OØ�a�a�a˜Ð(Ô)¨9°_Ô+EÐEÐEó    )r   r   r   r   r	   r
   )Ú__doc__Ú
__future__r   Únumpyr   Únumpy.typingr   r!   © r"   r    ú<module>r(      sb   ðð DÐ Cà "Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ø  Ð  Ð  Ð  Ð  Ð  ð%Fð %Fð %Fð %Fð %Fð %Fr"   