+
    
åûj÷} ã                  óL  € R t ^ RIHt ^ RIHtHtHtHt ^ RIt^ RIH	t	 ^ RI
Ht ^ RIHt ^ RIHt ^ RIHtHtHt ^ R	IHt ^ R
IHt . R#OtR R ltR$R R lltR R ltR R ltR R ltR R ltR R ltR%R R llt R R lt! ! R  R4      t" ! R! R]"4      t# ! R" R4      t$R# )&aß  Box containers: 2D, 3D and video boxes stored as inclusive corners, with conversions.

:class:`Boxes` stores 2D boxes as four ``(x, y)`` corners each, ``(N, 4, 2)`` for one image or ``(B, N, 4, 2)`` for a
batch; :class:`Boxes3D` stores 3D boxes as eight ``(x, y, z)`` corners each; :class:`VideoBoxes` stores the 2D boxes of
``(B, T)`` video frames. :meth:`~kornia.geometry.boxes.Boxes.from_tensor` and
:meth:`~kornia.geometry.boxes.Boxes3D.from_tensor` import boxes in one of several formats, ``'xyxy'`` and ``'xyzxyz'``
by default, and ``to_tensor`` exports them in any format, always as the axis-aligned bounds of the stored corners. The
stored corners are inclusive pixel centres, ``x_max - x_min + 1`` wide, as in :mod:`kornia.geometry.bbox`
(`#3934 <https://github.com/kornia/kornia/issues/3934>`_): the formats ending in ``_plus`` are inclusive, the others
exclusive. The ``Convention`` block of each class gives its formats, padded batches and validation.

Which class to use:

- 2D boxes of images, several per image, with padding, clamping, area filtering and masks: :class:`Boxes`.
- 2D boxes of video frames, exported with the temporal axis, ``(B, T, N, 4)`` in ``'xyxy'``: :class:`VideoBoxes`.
- 3D boxes in volumes: :class:`Boxes3D`.
- One box per image as a plain ``(B, 4, 2)`` corner tensor, without a container: the functions of
  :mod:`kornia.geometry.bbox`, such as :func:`~kornia.geometry.bbox.bbox_to_mask`.
- Points instead of boxes: :class:`~kornia.geometry.keypoints.Keypoints`.
)Úannotations)ÚAnyÚOptionalÚTupleÚcastN)ÚSize)Ú_emit_deprecation_warning)Ú_check_async)Úeye_like)Ú_to_device_nonblockingÚis_compilingÚis_exporting)Ú_cast_to_floating_point)Útransform_pointsÚBoxesÚBoxes3DÚ
VideoBoxesc               ó    € V ^8„  d   QhRRRR/# )é   Údtypeútorch.dtypeÚreturnÚbool© )Úformats   "ÚQC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\geometry\boxes.pyÚ__annotate__r   8   s   € ÷ ^ñ ^ Kð ^°Dñ ^ó    c                ó¢   € V \         P                  \         P                  \         P                  \         P                  \         P
                  39   # ©N)ÚtorchÚfloat16Úfloat32Úfloat64Úbfloat16Úhalf©r   s   &r   Ú_is_floating_point_dtyper'   8   s/   € Ø”U—]‘]¤E§M¡M´5·=±=Ä%Ç.Á.ÔRW×R\ÑR\Ð]Ñ]Ð]r   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Úboxeszlist[torch.Tensor]ÚmethodÚstrr   ztuple[torch.Tensor, list[int]]r   )r   s   "r   r   r   <   s#   € ÷ ñ Ð-ð °sð ÐGeñ r   c                óê  € \         ;QJ d    R V  4       F  '       d   K   RM	  RM! R V  4       4      '       g)   \        RV  Uu. uF  q"P                  NK  	  up R24      hVR8X  ds   \        R V  4       4      pV  Uu. uF  q#VP                  ^ ,          ,
          NK  	  pp\        P
                  P                  P                  P                  V RR7      pWT3# \        R	V R
24      hu upi u upi )z&Merge a list of boxes into one tensor.c              3  ó¦   "  € T FG  qP                   RR \        P                  ! ^^.4      8H  ;'       d    VP                  4       ^8H  x € KI  	  R# 5i)r   Néþÿÿÿ)Úshaper    r   Údim©Ú.0Úboxs   & r   Ú	<genexpr>Ú"_merge_box_list.<locals>.<genexpr>>   sA   é € ÐXÑRWÈ3�y‰y˜˜ˆ~¤§¢¨Q°¨FÓ!3Ñ3×FÐF¸¿¹»	ÀQ¹ÔFÓRWùs
   ‚2AµAFTz5Input boxes must be a list of (N, 4, 2) shaped. Got: Ú.Úpadc              3  óF   "  € T F  qP                   ^ ,          x € K  	  R# 5i)é    N)r/   r1   s   & r   r4   r5   B   s   é € Ð2©E S—I‘I˜a—L’L«Eùs   ‚!)Úbatch_firstÚ`z` is not implemented.)
ÚallÚ	TypeErrorr/   Úmaxr    ÚnnÚutilsÚrnnÚpad_sequenceÚNotImplementedError)r)   r*   r3   Úmax_NÚstatsÚoutputs   &&    r   Ú_merge_box_listrG   <   sÜ   € ç‹3ÑXÑRWÓX�3�3Š3ÑXÑRWÓX×XÒXÜÐOÑfkÓPlÑfkÐ_b×QZÔQZÑfkÑPlÐOmÐmnÐoÓpÐpà�„ÜÑ2©EÓ2Ó2ˆÙ16Ó7±¨#˜Ÿ™ 1�×%Ð%±ˆÐ7Ü—‘—‘×#Ñ#×0Ñ0°ÀDÐ0ÓIˆð ˆ=Ðô " A f XÐ-BÐ"CÓDÐDùò Qmùò 8s   ÁC+
Â "C0c               ó$   € V ^8„  d   QhRRRRRR/# )r   Úcountsz	list[int]Ú	num_boxesÚintr   útorch.Tensorr   )r   s   "r   r   r   K   s&   € ÷ Hñ H˜)ð H°ð H¸ñ Hr   c                óØ   € \         P                  ! V  Uu. uF  q!V,
          NK  	  upR\         P                  R7      p\         P                  ! VRR7      R,          VR,          8¬  # u upi )zmMark the last ``counts[i]`` of the ``num_boxes`` rows of each sample ``i`` in a ``(B, num_boxes)`` host mask.Úcpu©Údevicer   ©rP   N©ºNNNN)r    Ú	as_tensorÚlongÚarange)rI   rJ   ÚnÚreals   &&  r   Ú_padding_maskrY   K   sR   € ä�?Š?±6Ó:±6¨a¨ŸM˜M±6Ñ:À5ÔPU×PZÑPZÔ[€DÜ�<Š<˜	¨%Ô0°Õ6¸$¸w½-ÑGÐGùò ;s   •A'c               ó    € V ^8„  d   QhRRRR/# )r   Úkeyr   r   r   )r   s   "r   r   r   Q   s   € ÷ ñ �cð ˜cñ r   c                óÎ   € \        V \        P                  4      '       d   V P                  4       # \        V \        \
        34      '       d   \        V 4      ! R V  4       4      # V # )ziMove the tensors of an index key to the CPU, where the padding mask of a list-built :class:`Boxes` lives.c              3  ó8   "  € T F  p\        V4      x € K  	  R # 5ir   )Ú_key_on_host)r2   Úitems   & r   r4   Ú_key_on_host.<locals>.<genexpr>V   s   é € Ð<¹°œ d×+Ð+»ùs   ‚)Ú
isinstancer    ÚTensorrN   ÚtupleÚlistÚtype)r[   s   &r   r^   r^   Q   sJ   € ä�#”u—|‘|×$Ò$Ø�w‰w‹yÐÜ�#œœt�}×%Ò%Ü�CŒyÑ<¹Ó<Ó<Ð<Ø€Jr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r)   rL   ÚMr   r   )r   s   "r   r   r   Z   s!   € ÷ ,ñ ,˜Lð ,¨\ð ,¸lñ ,r   c                óº  € \        V4      pV P                  RR w  r#pV^ 8X  d   V # V P                  RW2,          V4      pVP                  ^8X  d   TMVP	                  ^ 4      pVP                  ^ ,          VP                  ^ ,          8w  d5   \        RVP                  ^ ,           RVP                  ^ ,           R24      h\        W4      pVP                  V 4      # )a]  Transform 3D and 2D in kornia format by applying the transformation matrix M.

Boxes and the transformation matrix could be batched or not.

Args:
    boxes: 2D quadrilaterals or 3D hexahedrons in kornia format.
    M: the transformation matrix of shape ``(3, 3)`` or ``(B, 3, 3)`` for 2D and ``(4, 4)`` or
        ``(B, 4, 4)`` for 3D hexahedron.

NúBatch size mismatch. Got z for boxes and z for the transformation matrix.éýÿÿÿéÿÿÿÿ)r   r/   ÚreshapeÚndimÚ	unsqueezeÚ
ValueErrorr   Úview_as)r)   rg   Úboxes_per_batchÚn_points_per_boxÚcoordinates_dimensionÚpointsÚtransformed_boxess   &&     r   Ú_transform_boxesrv   Z   sÍ   € ô 	  Ó"€Að @E¿{¹{È2È3Ð?OÑ<€OÐ'<Ø˜!ÔØˆØ�]‰]˜2Ð/ÕAÐCXÓY€FØ�V‰V�qŒ[‰˜aŸk™k¨!›n€Aà‡|�|�A…˜!Ÿ'™' !�*Ô$ÜØ'¨¯©°Q­Ð'8¸ÈÏÉÐPQÍ
À|ÐSrÐsó
ð 	
ô '7°qÓ&AÐØ×$Ñ$ UÓ+Ð+r   c          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )r   ÚxminrL   ÚyminÚwidthÚheightr   r   )r   s   "r   r   r   w   s4   € ÷ ñ Ø
ðØ*ðØ3?ðØIUðàñr   c                ó„  € V P                   VP                   u;8X  d,   VP                   u;8X  d   VP                   u;8X  d   ^8X  g   M \        R4      h\        P                  ! V P                  ^ ,          V P                  ^,          ^^3V P
                  V P                  R7      pV P                  R4      VR&   VP                  R4      VR&   VR;;,          V^,
          ,          uu&   VR;;,          V^,
          ,          uu&   VR;;,          V^,
          ,          uu&   VR	;;,          V^,
          ,          uu&   V# )
r   zXWe expect to create a batch of 2D boxes (quadrilaterals) in vertices format (B, N, 4, 2)rO   rk   ©.r9   ©.é   ©.r   r9   ©.r   r9   ©.r   r   ©.é   r   )rm   ro   r    Úzerosr/   rP   r   rn   )rx   ry   rz   r{   Úpolygonss   &&&& r   Ú_boxes_to_polygonsr‡   w   sê   € ð �9‰9˜Ÿ	™	ÖC U§Z¡ZÖC°6·;±;ÖCÀ!ÖCÜÐsÓtÐtô �{Š{˜DŸJ™J q�M¨4¯:©:°a­=¸!¸QÐ?ÈÏÉÐ[_×[eÑ[eÔf€HØ—~‘~ bÓ)€HˆVÑØ—~‘~ bÓ)€HˆVÑàˆY×˜5 1�9Õ$ÓØˆY×˜5 1�9Õ$ÓØˆY×˜6 A�:Õ%ÓØˆY×˜6 A�:Õ%ÓØ€Or   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   r)   rL   rz   r{   r   ÚNoner   )r   s   "r   r   r   ‰   s/   € ÷ Cñ C ð C°\ð CÈ<ð CÐ\`ñ Cr   c                óV  € \         P                  ! \         P                  ! V 4      ( P                  4       V^ 8*  P                  4       V^ 8*  P                  4       34      P	                  4       w  r4pV'       d   \        R4      hV'       d   \        R4      hV'       d   \        R4      hR# )aF  Raise the first of the non-finite, width and height errors, reading all three checks in one host transfer.

The three reductions run on the device of ``boxes`` and come back together, so a CUDA box costs one device
synchronization instead of three. The errors, their messages and their order are those of the separate checks.
ú'Some boxes have non-finite coordinates.ú%Some boxes have negative widths or 0.ú&Some boxes have negative heights or 0.N)r    ÚstackÚisfiniteÚanyÚtolistro   )r)   rz   r{   Ú
non_finiteÚ	bad_widthÚ
bad_heights   &&&   r   Ú_validate_box_valuesr•   ‰   s�   € ô ).¯ªÜ�>Š>˜%Ó Ð
 ×	%Ñ	%Ó	'¨%°1©*×)9Ñ)9Ó);¸fÈ¹k×=NÑ=NÓ=PÐQó)ç�fƒhñ &€J˜:÷ ÜÐBÓCÐCßÜÐ@ÓAÐAßÜÐAÓBÐBñ r   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   r)   rL   Úmoder+   Úvalidate_boxesr   r   r   )r   s   "r   r   r   š   s0   € ÷ :Dñ :D Lð :D¸ð :DÐVZð :DÐfrñ :Dr   c                óª  € VP                  4       pVP                  R4      '       ds   V P                  ^8H  p^V P                  u;8:  d   ^8:  d.   M M*V P                  RR \        P
                  ! ^^.4      8X  g   \        RV RV P                   R24      hM…VP                  R4      '       da   V P                  ^8H  p^V P                  u;8:  d   ^8:  d   M MV P                  R,          ^8X  g   \        RV RV P                   R24      hM\        RV 24      h\        V 4      p V'       d   T MV P                  ^ 4      p V'       dk   \        4       '       g[   V P                  4       ^ 8”  dF   VP                  R4      '       d/   \        \        P                  ! V 4      P                  4       R	4       VP                  R4      '       dg   VR8X  d9   V P                  4       pVR,          ^,
          VR&   VR,          ^,
          VR&   EM-VR
8X  d   V P                  4       pEM\        RV 24      hVP                  R4      '       dâ   VR8X  d/   V R,          V R,          ,
          V R,          V R,          ,
          reMjVR8X  d=   V R,          V R,          ,
          ^,           V R,          V R,          ,
          ^,           reM'VR8X  d   V R,          V R,          reM\        RV 24      hV'       d   \        4       '       g   \!        WV4       V R,          V R,          r‡\#        WxWe4      pM\        RV 24      hV'       d   V# VP%                  ^ 4      # )z%Convert from boxes to quadrilaterals.ÚverticesNz3Boxes shape must be (N, 4, 2) or (B, N, 4, 2) when z mode. Got r6   Úxyz-Boxes shape must be (N, 4) or (B, N, 4) when úUnknown mode r‹   Úvertices_plusÚxyxyÚ	xyxy_plusÚxywhr.   rk   ).:r   r„   Nr9   ).:r   NNr   ©.r„   r~   ©.r   r}   )ÚlowerÚ
startswithrm   r/   r    r   ro   r   rn   r   Únumelr	   r�   r<   Úcloner   r•   r‡   Úsqueeze)	r)   r—   r˜   ÚbatchedÚquadrilateralsr{   rz   rx   ry   s	   &&&      r   Ú_boxes_to_quadrilateralsrª   š   sÀ  € à�:‰:‹<€Dà‡��z×"Ò"Ø—*‘* ‘/ˆØ�U—Z‘ZÖ$ 1×$¨¯©°R°SÐ)9¼U¿ZºZÈÈAÈÓ=OÔ)OÜÐRÐSWÐRXÐXcÐdi×doÑdoÐcpÐpqÐrÓsÐsð *Pà	�‰˜×	Ò	Ø—*‘* ‘/ˆØ�U—Z‘ZÖ$ 1×$¨¯©°R­¸AÔ)=ÜÐLÈTÈFÐR]Ð^c×^iÑ^iÐ]jÐjkÐlÓmÐmð *>ô ˜=¨¨Ð/Ó0Ð0ä# EÓ*€Eß‰E %§/¡/°!Ó"4€E÷
 œlŸnšn°·±³ÀÔ1BÀtÇÁÐWa×GbÒGbÜ”U—^’^ EÓ*×.Ñ.Ó0Ð2[Ô\à‡��z×"Ò"Ø�:ÔØ"Ÿ[™[›]ˆNð +9¸Õ*EÈÕ*IˆN˜;Ñ'Ø)7¸
Õ)CÀaÕ)GˆN˜:Ó&Ø�_Ô$à"Ÿ[™[›]ŠNä˜}¨T¨FÐ3Ó4Ð4à	�‰˜×	Ò	Ø�6Œ>Ø! &�M¨E°&­MÕ9¸5À½=È5ÐQWÍ=Õ;X‘EØ�[Ô Ø! &�M¨E°&­MÕ9¸AÕ=¸uÀV½}ÈuÐU[Í}Õ?\Ð_`Õ?`‘EØ�VŒ^Ø! &�M¨5°­=‘Eä˜}¨T¨FÐ3Ó4Ð4÷ ¤,§.¢.Ü  ¨vÔ6à˜6•] E¨&¥MˆdÜ+¨D¸ÓF‰ä˜=¨¨Ð/Ó0Ð0ç$ˆ>ÐC¨.×*@Ñ*@ÀÓ*CÐCr   c               ó4   € V ^8„  d   QhRRRRRRRRRRRRRR/# )	r   rx   rL   ry   Úzminrz   r{   Údepthr   r   )r   s   "r   r   r   ×   sN   € ÷ >ñ >Ø
ð>à
ð>ð ð>ð ð	>ð
 ð>ð ð>ð ñ>r   c                ó˜  € V P                   VP                   u;8X  dP   VP                   u;8X  d>   VP                   u;8X  d,   VP                   u;8X  d   VP                   u;8X  d   ^8X  g   M \        R4      h\        P                  ! V P                  ^ ,          V P                  ^,          ^^3V P
                  V P                  R7      pV P                  R4      VR&   VP                  R4      VR&   VP                  R4      VR&   VR;;,          V^,
          ,          uu&   VR	;;,          V^,
          ,          uu&   VR
;;,          V^,
          ,          uu&   VR;;,          V^,
          ,          uu&   VP                  4       pVR;;,          VP                  R4      ^,
          ,          uu&   \        P                  ! Wg.RR7      # )r   zUWe expect to create a batch of 3D boxes (hexahedrons) in vertices format (B, N, 8, 3)rO   ©r0   rk   r}   r~   r¢   r€   r�   r‚   rƒ   r.   )
rm   ro   r    r…   r/   rP   r   rn   r¦   Úcat)rx   ry   r¬   rz   r{   r­   Úfront_verticesÚback_verticess   &&&&&&  r   Ú_boxes3d_to_polygons3dr³   ×   sM  € ð �9‰9˜Ÿ	™	Ö^ T§Y¡YÖ^°%·*±*Ö^ÀÇÁÖ^ÈuÏzÉzÖ^Ð]^Ö^ÜÐpÓqÐqô —[’[ $§*¡*¨Q¥-°·±¸AµÀÀ1Ð!EÈdÏkÉkÐae×akÑakÔl€NØ!Ÿ^™^¨BÓ/€N�6ÑØ!Ÿ^™^¨BÓ/€N�6ÑØ!Ÿ^™^¨BÓ/€N�6Ñà�9× ¨¥Õ*ÓØ�9× ¨¥Õ*ÓØ�9× ¨!¥Õ+ÓØ�9× ¨!¥Õ+Óð #×(Ñ(Ó*€MØ�&×˜UŸ_™_¨RÓ0°1Õ4Õ4Óä�9Š9�nÐ4¸"Ô=Ð=r   c                  ó$  € ] tR t^õtRtRHR R lltR R ltR R ltR R	 ltR
 R lt	R R lt
]R R l4       tR R ltR R lt]R R l4       tR R ltRIR R lltR R ltRIR R lltR R ltR  R! ltR" R# ltRJR% R& lltRKR' R( lltRJR) R* lltR+ R, lt]RLR- R. ll4       tRMR/ R0 lltR1 R2 ltRIR3 R4 lltR5 R6 lt RNR7 R8 llt!]R9 R: l4       t"]R; R< l4       t#]R= R> l4       t$]R? R@ l4       t%RORA RB llt&RC RD lt'RE RF lt(RGt)R$# )Pr   ae"  Store 2D boxes as inclusive corners, converting to and from xyxy, xywh and vertices.

``boxes = Boxes.from_tensor(xyxy, mode='xyxy')`` takes the ``(N, 4)`` boxes of one image or the ``(B, N, 4)`` boxes
of a batch (``(N, 4, 2)`` or ``(B, N, 4, 2)`` corners in the vertex modes, or a list of per-image tensors) and
stores them as inclusive corners; ``boxes.to_tensor('xywh')`` exports them in any mode, with the same batch layout.
In between, :meth:`transform_boxes` applies ``3 x 3`` matrices to all four corners, :meth:`to_mask` draws
``(N, H, W)`` or ``(B, N, H, W)`` masks, :meth:`pad` shifts the corners by image padding, :meth:`clamp` limits
them to per-image bounds, :meth:`filter_boxes_by_area` removes boxes and :meth:`merge` appends others.
``Boxes(corners)`` wraps inclusive ``'vertices_plus'`` corners as they are.
:class:`~kornia.augmentation.container.AugmentationSequential` accepts a :class:`Boxes` and transforms it with the
images. For one box per image as a plain ``(B, 4, 2)`` tensor, use the :mod:`kornia.geometry.bbox` functions; for
3D boxes, :class:`Boxes3D`; for the boxes of video frames, :class:`VideoBoxes`.

Args:
    boxes: 2D boxes, shape of ``(N, 4, 2)``, ``(B, N, 4, 2)`` or a list of ``(N, 4, 2)``.
        See below for more details.
    raise_if_not_floating_point: flag to control floating point casting behaviour when `boxes` is not a
        floating point tensor. True to raise an error when `boxes` isn't a floating point tensor, False
        to cast to ``float32``, or ``float64`` when that is the default dtype.
        Floating-point input keeps its dtype.
    mode: Representation label reused as the default output mode by :meth:`to_tensor`. The constructor does not
        convert ``boxes``; use :meth:`from_tensor` to import another representation.

Convention:
    - A box is a quadrilateral of four floating-point ``(x, y)`` vertices, ``(N, 4, 2)`` or
      ``(B, N, 4, 2)``, built in clockwise top-left, top-right, bottom-right, bottom-left order;
      :meth:`transform_boxes` can make it an arbitrary (rotated) quadrilateral.
    - The stored form is **inclusive** (``'vertices_plus'``): ``width = xmax - xmin + 1``. The exclusive
      ``'xyxy'``, ``'xywh'`` and ``'vertices'`` modes are converted by :meth:`from_tensor` and
      :meth:`to_tensor`; the constructor converts nothing and only records ``mode``.
    - :meth:`to_tensor` reduces the vertices with ``amin``/``amax``, so every export is an axis-aligned
      bounding box and ``to_tensor('vertices_plus')`` is not the identity for a rotated box.
    - :meth:`get_boxes_shape` returns ``(heights, widths)``; padding entries of a list-backed object report
      as 1-by-1 boxes (the inclusive ``+1``, `#3934 <https://github.com/kornia/kornia/issues/3934>`_).
    - :func:`~kornia.geometry.bbox.infer_bbox_shape` and :func:`~kornia.geometry.bbox.bbox_to_mask` read
      their input as inclusive: pass them the ``'vertices_plus'`` export, unbatched.
      :func:`~kornia.geometry.bbox.nms` takes exclusive ``xyxy``.
    - The modes of :meth:`from_tensor` and :meth:`to_tensor`, case-insensitive: ``'xyxy'`` is
      ``(xmin, ymin, xmax, ymax)`` with ``xmax`` and ``ymax`` one past the last pixel, ``'xyxy_plus'`` the same
      on the last pixel, ``'xywh'`` is ``(xmin, ymin, width, height)``, ``'vertices'`` the corners with ``xmax``
      and ``ymax`` one past the last pixel, and ``'vertices_plus'`` the stored corners.
      ``from_tensor(torch.tensor([[[0., 0., 10., 20.]]]))`` stores ``[[0, 0], [9, 0], [9, 19], [0, 19]]``,
      which ``to_tensor`` exports as ``[0, 0, 10, 20]`` in ``'xyxy'`` and ``'xywh'`` and ``[0, 0, 9, 19]`` in
      ``'xyxy_plus'``.
    - With ``validate_boxes=True``, every mode rejects a non-finite coordinate. The ``'xy*'`` modes raise
      ``ValueError`` and also reject non-positive extents. The vertex modes raise ``RuntimeError`` through
      ``torch._assert_async`` (by the next synchronization on CUDA, and on MPS from torch 2.13), so they stay
      ``fullgraph``-compilable, and take no extent or shape check, so the arbitrary quadrilaterals of
      :meth:`transform_boxes` import unchanged.
    - The constructor rejects an integer tensor unless ``raise_if_not_floating_point=False`` (for list inputs,
      every element is checked); :meth:`from_tensor` casts integer input to ``float32``,
      or ``float64`` when that is the default dtype.
    - A list of per-image tensors, ``(N_i, 4)`` or ``(N_i, 4, 2)`` in :meth:`from_tensor` and ``(N_i, 4, 2)``
      in the constructor, is zero-padded to one ``(B, max N_i, 4, 2)`` batch; :meth:`to_tensor` then returns a
      list trimmed back to each image's boxes, or the padded tensor with ``as_padded_sequence=True``.
    - Which rows are padding is recorded per box and follows the coordinates through indexing, item assignment,
      :meth:`index_put` and :meth:`merge`: a padding row written elsewhere stays padding, and a :class:`Boxes`
      that does not come from a list writes real boxes. A raw tensor passed to :meth:`index_put` changes only
      coordinates. Writing padding to a :class:`Boxes` that does not come from a list marks those rows invalid,
      since that object has no trimmed export.
    - A selection by integer or slice shares its coordinates, validity and padding with the object it came from,
      as tensor indexing does, and any other key copies all three. :meth:`to` and :meth:`type` to another device or
      dtype, and an in-place :meth:`transform_boxes`, :meth:`translate` or :meth:`merge`, end the sharing of all
      three, for the object they are called on, whether it is the selection or the original.
    - :meth:`filter_boxes_by_area` removes boxes without changing the shape: it zeroes their corners and marks
      them invalid, and every export of an invalid box is exact zeros, after later transforms too.
    - :meth:`transform_boxes`, :meth:`translate`, :meth:`clamp`, :meth:`filter_boxes_by_area`, :meth:`merge`
      and :meth:`index_put` are non-mutating by default and return a new object; with ``inplace=True`` they
      update and return ``self``. :meth:`pad` and :meth:`unpad` always shift ``self``. The constructor wraps a
      floating-point tensor without copying it, so item assignment and the in-place updates of :meth:`pad`,
      :meth:`unpad`, :meth:`clamp`, :meth:`filter_boxes_by_area` and :meth:`index_put` reach the caller's tensor.
    - Integer indexing selects one image's box set for batched input, or one box with shape ``(1, 4, 2)`` for
      unbatched input. Scalar integer tensors follow the same rule.

.. warning::
    The inclusive ``+1`` differs from torchvision, COCO and albumentations:
    `#3934 <https://github.com/kornia/kornia/issues/3934>`_. A sub-unit extent (normalized ``[0, 1]`` boxes)
    is corrupted by the ``- 1`` of the converting modes: `#4061 <https://github.com/kornia/kornia/issues/4061>`_.
    Passing the ``'vertices'`` export to the bbox helpers reads one pixel larger:
    `#4009 <https://github.com/kornia/kornia/issues/4009>`_. :meth:`compute_area` is the shoelace area of the
    stored inclusive vertices, ``(width - 1) * (height - 1)``:
    `#4010 <https://github.com/kornia/kornia/issues/4010>`_. :func:`~kornia.geometry.bbox.nms` is exclusive:
    `#4008 <https://github.com/kornia/kornia/issues/4008>`_. :meth:`to_mask` and
    :func:`~kornia.geometry.bbox.bbox_to_mask` agree on ``(height, width)`` once that function is called with
    ``size``; its deprecated ``width, height`` form takes the opposite order:
    `#4014 <https://github.com/kornia/kornia/issues/4014>`_. The integer-input split is
    `#4012 <https://github.com/kornia/kornia/issues/4012>`_. ``'vertices'`` subtracts the inclusive offset at
    fixed vertex slots, so it deforms a quadrilateral that is not an axis-aligned rectangle in clockwise order:
    `#3934 <https://github.com/kornia/kornia/issues/3934>`_. ``trim`` was never implemented and is deprecated:
    `#4017 <https://github.com/kornia/kornia/issues/4017>`_.

See Also:
    - :class:`Boxes3D`: 3D boxes as eight corners, from ``(N, 6)`` boxes, with no list input, padding or
      filtering.
    - :class:`VideoBoxes`: the 2D boxes of ``(B, T)`` video frames, exported with the temporal axis.
    - :func:`~kornia.geometry.bbox.bbox_to_mask`: the mask of one box per image of a plain ``(B, 4, 2)`` tensor,
      with unrounded inclusive bounds.
    - :func:`~kornia.geometry.bbox.transform_bbox`: transforms plain ``xyxy`` or ``xywh`` tensors through their two
      endpoints only.
    - :func:`~kornia.geometry.bbox.nms`: suppresses overlapping boxes of one image, given the ``'xyxy'`` export.
    - :class:`~kornia.geometry.keypoints.Keypoints`: ``(x, y)`` points in the same pixel frame, with matching pad,
      unpad and transform methods.

c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r   r)   ú!torch.Tensor | list[torch.Tensor]Úraise_if_not_floating_pointr   r—   r+   r   r‰   r   )r   s   "r   r   ÚBoxes.__annotate___  s8   € ÷ 6Mñ 6Mà0ð6Mð &*ð6Mð ð	6Mð
 
ñ6Mr   c                	ó‚  € R p\        V\        4      '       Ed   V'       d1   \        R V 4       R 4      pVe   \        RVP                   24      hMÓ\
        ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      '       dš   \        P                  ! \        P                  ! 4       \        P                  4      pV F;  pVP                  4       '       g   K  \        P                  ! WgP                  4      pK=  	  V Uu. uF  qwP                  VR7      NK  	  pp\        V4      w  r\        V\        P                  4      '       g   \        R\        V4       R24      hVP                  4       '       g,   V'       d   \        RVP                   24      h\!        V4      p\#        VP$                  4      ^ 8X  d   VP'                  R4      p^VP(                  u;8:  d   ^8:  d   M MVP$                  RR  R8X  g   \        R	VP$                   R24      hVP(                  ^8g  V n        Wn        W0n        \        P0                  ! VP$                  R R VP2                  \        P4                  R
7      V n        R V n        Ve.   V P;                  \=        WAP$                  ^,          4      4       R # R # u upi )Nc              3  óT   "  € T F  qP                  4       '       d   K  Vx € K   	  R # 5ir   ©Úis_floating_pointr1   s   & r   r4   Ú!Boxes.__init__.<locals>.<genexpr>j  s   é € ÐI¡E˜S×1FÑ1F×1H—S’S£Eùs   ‚(ž
(ú+Coordinates must be in floating point. Got c              3  óJ   "  € T F  qP                  4       '       * x € K  	  R # 5ir   r»   r1   s   & r   r4   r½   o  s   é € ÐB¹E°S×.Ñ.Ó0×0Ñ0»Eùs   ‚!#TFr&   ú"Input boxes is not a Tensor. Got: r6   z3Boxes shape must be (N, 4, 2) or (B, N, 4, 2). Got rO   )rk   é   r.   )rÁ   r   )ra   rd   Únextro   r   r�   r    Úpromote_typesÚget_default_dtyper"   r¼   ÚtorG   rb   r=   re   r   Úlenr/   rl   rm   Ú_is_batchedÚ_dataÚ_modeÚonesrP   r   Ú_validÚ_paddingÚ_set_paddingrY   )Úselfr)   r·   r—   Úpadding_countsÚinvalid_boxÚmerged_dtyper3   s   &&&&    r   Ú__init__ÚBoxes.__init___  s%  € ð /3ˆä�eœT×"Ó"ß*Ü"ÙI¡EÓIØó�ð Ò*Ü$Ð'RÐS^×SdÑSdÐReÐ%fÓgÐgð +ç“ÑB¹EÓB——’ÑB¹EÓB×BÒBÜ$×2Ò2´5×3JÒ3JÓ3LÌeÏmÉmÓ\�Û �CØ×,Ñ,×.Ô.Ü',×':Ò':¸<ÏÉÓ'Sšñ !ñ @EÓE¹u¸Ÿ™ l˜Ö3¹u�ÐEÜ$3°EÓ$:Ñ!ˆEä˜%¤§¡×.Ò.ÜÐ@ÄÀeÃÀÈQÐOÓPÐPà×&Ñ&×(Ò(ß*Ü Ð#NÈuÏ{É{ÈmÐ!\Ó]Ð]ä+¨EÓ2ˆEäˆu�{‰{Ó˜qÔ Ø—M‘M 'Ó*ˆEà�U—Z‘ZÖ$ 1×$¨¯©°R°SÐ)9¸VÔ)CÜÐRÐSX×S^ÑS^ÐR_Ð_`ÐaÓbÐbà Ÿ:™:¨™?ˆÔàŒ
ØŒ
ô —j’j §¡¨S¨bÐ!1¸%¿,¹,ÌeÏjÉjÔYˆŒØ04ˆŒØÒ%Ø×Ñœm¨N¿K¹KÈ½NÓKÖLñ &ùòA Fs   Ä	J<c               ó    € V ^8„  d   QhRRRR/# )r   Ústatezdict[str, Any]r   r‰   r   )r   s   "r   r   r¸   —  s   € ÷ 	0ñ 	0 .ð 	0°Tñ 	0r   c                	ó|  € V P                   P                  VP                  4        UUu/ uF  w  r#VR 8w  g   K  W#bK  	  upp4       RV9  dX   \        P                  ! V P
                  P                  RR V P
                  P                  \        P                  R7      V n	        RV9  d\   RV n
        VP                  R 4      e@   V P                  \        VR ,          V P
                  P                  ^,          4      4       R# R# V P                  e"   V P                  P                  4       V n
        R# R# u uppi )Ú_NrË   NrO   rÌ   r.   )Ú__dict__ÚupdateÚitemsr    rÊ   rÈ   r/   rP   r   rË   rÌ   ÚgetrÍ   rY   rN   )rÎ   rÕ   ÚnameÚvalues   &&  r   Ú__setstate__ÚBoxes.__setstate__—  sç   € Ø�‰×Ñ¸U¿[¹[¼]Ô[¹]©k¨dÈdÐVZÉlœk˜dšk¹]Ò[Ô\Ø˜5Ô ÜŸ*š* T§Z¡Z×%5Ñ%5°c°rÐ%:À4Ç:Á:×CTÑCTÔ\a×\fÑ\fÔgˆDŒKØ˜UÔ"Ø ˆDŒMØ�y‰y˜‹Ò*Ø×!Ñ!¤-°°dµ¸T¿Z¹Z×=MÑ=MÈaÕ=PÓ"QÖRñ +à�]‰]Ò&Ø ŸM™M×-Ñ-Ó/ˆDŽMñ 'ùó \s
   ©D8
¹D8
c               ó    € V ^8„  d   QhRRRR/# ©r   ÚpaddingúOptional[torch.Tensor]r   r‰   r   )r   s   "r   r   r¸   ¢  s   € ÷  ñ  Ð$:ð  ¸tñ  r   c                ó   € Wn         R# )z[Record the host mask of the rows a list input added, or ``None`` for an object without any.N)rÌ   ©rÎ   râ   s   &&r   rÍ   ÚBoxes._set_padding¢  s   € àŽr   c               ó   € V ^8„  d   QhRR/# )r   r   r‰   r   )r   s   "r   r   r¸   ¦  s   € ÷ 2ñ 2˜tñ 2r   c                óÐ   € V P                   P                  V P                  P                  RR7      V n         V P                  e"   V P                  P                  4       V n        R# R# )zcGive ``_valid`` and ``_padding`` storage of their own, ``_valid`` on the device of the coordinates.T)rP   ÚcopyN)rË   rÅ   rÈ   rP   rÌ   r¦   ©rÎ   s   &r   Ú_detach_masksÚBoxes._detach_masks¦  sG   € à—k‘k—n‘n¨D¯J©J×,=Ñ,=ÀD�nÓIˆŒØ�=‰=Ò$Ø ŸM™M×/Ñ/Ó1ˆDŽMñ %r   c               ó    € V ^8„  d   QhRRRR/# )r   ÚdatarL   r   r‰   r   )r   s   "r   r   r¸   ¬  s   € ÷ !ñ ! ð !°$ñ !r   c                óT   € WP                   Jd   Wn         V P                  4        R# R# )zÎReplace the coordinates of this object, and stop sharing its masks if ``data`` is another tensor.

Whatever shared the old coordinates, a selection or the object it came from, keeps them and the old masks.
N)rÈ   rë   )rÎ   rî   s   &&r   Ú_rebind_dataÚBoxes._rebind_data¬  s$   € ð
 —z‘zÓ!ØŒJØ×ÑÖ ñ "r   c               ó   € V ^8„  d   QhRR/# ©r   r   rL   r   )r   s   "r   r   r¸   µ  s   € ÷ Xñ X¨ñ Xr   c                ó®   € V P                   f   V P                  # V P                  \        V P                   V P                  P                  4      ( ,          # )zeReturn ``_valid`` with the padding rows marked invalid, for a destination that has no trimmed export.)rÌ   rË   r   rP   rê   s   &r   Ú_valid_without_paddingÚBoxes._valid_without_paddingµ  s>   € à�=‰=Ò Ø—;‘;ÐØ�{‰{Ô4°T·]±]ÀDÇKÁK×DVÑDVÓWÐWÕWÐWr   c               ó   € V ^8„  d   QhRR/# )r   r   zOptional[list[int]]r   )r   s   "r   r   r¸   ¼  s   € ÷ 2ñ 2Ð'ñ 2r   c                óš   € V P                   e   V P                  '       g   R# V P                   P                  RR7      P                  4       # )zcReturn the number of padding rows of each sample, or ``None`` for an object with no trimmed export.Nr¯   rk   )rÌ   rÇ   Úsumr‘   rê   s   &r   r×   ÚBoxes._N»  s=   € ð �=‰=Ò ¨×(8×(8Ð(8ÙØ�}‰}× Ñ  RÐ Ó(×/Ñ/Ó1Ð1r   c               ó    € V ^8„  d   QhRRRR/# )r   r[   úslice | int | torch.Tensorr   r   r   )r   s   "r   r   r¸   Â  s   € ÷ ñ Ð9ð ¸eñ r   c                	ó6  € V P                   V,          pVP                  ^8H  ;'       d    \        V\        4      '       * pV'       d   VP	                  ^ 4      p\        V 4      ! VR4      pV P                  Vn        V P                  V,          pV'       d   VP	                  ^ 4      MTVn        V P                  e=   V P                  \        V4      ,          pV'       d   VP	                  ^ 4      MTVn        VP                   VJd   VP                  4        V# )r   F)rÈ   rm   ra   rc   rn   re   rÉ   rË   rÌ   r^   rë   )rÎ   r[   ÚselectedÚone_boxÚnew_boxÚvalidrâ   s   &&     r   Ú__getitem__ÚBoxes.__getitem__Â  sÐ   € Ø—:‘:˜c•?ˆà—-‘- 1Ñ$×CÐC¬Z¸¼UÓ-CÔ)CˆßØ×)Ñ)¨!Ó,ˆHÜ�t”*˜X uÓ-ˆØŸ
™
ˆŒØ—‘˜CÕ ˆß/6˜Ÿ™¨Ô+¸EˆŒØ�=‰=Ò$Ø—m‘m¤L°Ó$5Õ6ˆGß7>˜w×0Ñ0°Ô3ÀGˆGÔØ�=‰= Ó(Ø×!Ñ!Ô#Øˆr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r[   rü   rÝ   r   r   r   )r   s   "r   r   r¸   Ó  s"   € ÷ ñ Ð9ð À%ð ÈEñ r   c                	ó(  € VP                   V P                   V&   V P                  f    VP                  4       V P                  V&   V # VP                  V P                  V&   VP                  f   RMVP                  V P                  \	        V4      &   V # ©NF)rÈ   rÌ   rõ   rË   r^   ©rÎ   r[   rÝ   s   &&&r   Ú__setitem__ÚBoxes.__setitem__Ó  sy   € ØŸ+™+ˆ�
‰
�3‰Ø�=‰=Ò Ø$×;Ñ;Ó=ˆD�K‰K˜Ñð ˆð  %Ÿ|™|ˆD�K‰K˜ÑØ8=¿¹Ò8N©uÐTY×TbÑTbˆD�M‰Mœ, sÓ+Ñ,Øˆr   c               ó   € V ^8„  d   QhRR/# ©r   r   ztuple[int, ...] | Sizer   )r   s   "r   r   r¸   Ý  s   € ÷ 
ñ 
Ð-ñ 
r   c                ó.   € V P                   P                  # )ab  Return the tensor shape used to store the boxes.

Returns:
    Shape of :attr:`data`. For unbatched boxes this is usually
    ``(N, 4, 2)``, where :math:`N` is the number of boxes, ``4``
    is the number of corner vertices, and ``2`` stores ``(x, y)``.
    For batched boxes the shape is usually ``(B, N, 4, 2)``, where
    :math:`B` is the batch size.
©rî   r/   rê   s   &r   r/   ÚBoxes.shapeÜ  s   € ð �y‰y�‰Ðr   c               ó   € V ^8„  d   QhRR/# )r   r   z!tuple[torch.Tensor, torch.Tensor]r   )r   s   "r   r   r¸   é  s   € ÷ ñ Ð!Bñ r   c                ó€   € \        \        P                  V P                  RRR7      4      pVR,          VR,          r2W23# )aš  Compute boxes heights and widths.

See the Convention block on :class:`~kornia.geometry.boxes.Boxes`.

Returns:
    - Boxes heights, shape of ``(N,)`` or ``(B,N)``.
    - Boxes widths, shape of ``(N,)`` or ``(B,N)``.

Example:
    >>> boxes_xyxy = torch.tensor([[[1,1,2,2],[1,1,3,2]]])
    >>> boxes = Boxes.from_tensor(boxes_xyxy)
    >>> boxes.get_boxes_shape()
    (tensor([[1., 1.]]), tensor([[1., 2.]]))

r    T©Úas_padded_sequencer¢   r¡   )r   r    rb   Ú	to_tensor)rÎ   Ú
boxes_xywhÚwidthsÚheightss   &   r   Úget_boxes_shapeÚBoxes.get_boxes_shapeé  s;   € ô  œ%Ÿ,™,¨¯©°vÐRV¨Ó(WÓXˆ
Ø$ VÕ,¨j¸Õ.@�ØˆÐr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r)   r   Úinplacer   r   r   )r   s   "r   r   r¸   ý  s!   € ÷ -ñ -˜5ð -¨4ð -¸Eñ -r   c                óD  € RpV P                   f   VP                   eà   V P                  '       g   VP                  '       d†   V P                  P                  ^ ,          VP                  P                  ^ ,          8w  dI   \        RV P                  P                  ^ ,           RVP                  P                  ^ ,           R24      h\        P                  ! W3 Uu. uF  qDP                  4       NK  	  upRR7      p\        P                  ! V P                  VP                  .R	R7      p\        P                  ! V P                  VP                  .RR7      pVe‡   V P                  '       du   VP                  4       P                  RRR7      pVP                  RV4      p\        WuP                  4      pVP                  VR
,          R	R7      pVP                  RV4      pV'       d   T MV P!                  4       pWXn        Whn	        VP#                  V4       V# u upi )aœ  Merge boxes.

See the Convention block on :class:`~kornia.geometry.boxes.Boxes`.

For batched boxes, if the current instance holds ``(B, N, 4, 2)`` and
the incoming boxes holds ``(B, M, 4, 2)``, the merge results in
``(B, N + M, 4, 2)``.

For unbatched boxes, if the current instance holds ``(N, 4, 2)`` and
the incoming boxes holds ``(M, 4, 2)``, the merge results in
``(N + M, 4, 2)``.

Args:
    boxes: 2D boxes.
    inplace: do transform in-place and return self.

Note:
    When either input was created from a list, each batch row is repacked
    so that its real boxes precede all of its padding, and the merged
    object exports a list trimmed back to them.

Nri   z for self and z for boxes.r¯   T)r0   Ústablerk   rj   ©.NN)rÌ   rÇ   rÈ   r/   rî   ro   r    r°   Ú_padding_or_realrË   rU   ÚargsortÚgatherr   rP   Útake_along_dimr¦   rÍ   )	rÎ   r)   r  râ   Úoperandrî   r  ÚorderÚobjs	   &&&      r   ÚmergeÚBoxes.mergeý  s«  € ð. +/ˆØ�=‰=Ò$¨¯©Ò(BØ× × Ð  E×$5×$5Ð$5¸4¿:¹:×;KÑ;KÈAÕ;NÐRW×R\ÑR\×RbÑRbÐcdÕReÔ;eÜ Ø/°·
±
×0@Ñ0@ÀÕ0CÐ/DÀNÐSX×S]ÑS]×ScÑScÐdeÕSfÐRgÐgrÐsóð ô —i’iÈDÉ=Ó YÉ=À×!9Ñ!9Ö!;É=Ñ YÐ_aÔbˆGä�yŠy˜$Ÿ*™* e§j¡jÐ1°rÔ:ˆÜ—	’	˜4Ÿ;™;¨¯©Ð5¸2Ô>ˆàÒ 4×#3×#3Ð#3Ø—L‘L“N×*Ñ*¨r¸$Ð*Ó?ˆEØ—n‘n R¨Ó/ˆGÜ*¨5·+±+Ó>ˆEØ×&Ñ& u¨_Õ'=À2Ð&ÓFˆDØ—L‘L  UÓ+ˆEç‰d 4§:¡:£<ˆØŒ	ØŒ
Ø×Ñ˜Ô!Øˆ
ùò! !Zs   ÃHc               ó   € V ^8„  d   QhRR/# ró   r   )r   s   "r   r   r¸   ,  s   € ÷ Nñ N ,ñ Nr   c                ó¬   € V P                   e   V P                   # \        P                  ! V P                  P                  R\        P
                  R7      # )zYReturn the host padding mask, all ``False`` for an object that does not come from a list.rN   rO   )rÌ   r    r…   rË   r/   r   rê   s   &r   r  ÚBoxes._padding_or_real,  s7   € à�=‰=Ò$Ø—=‘=Ð Ü�{Š{˜4Ÿ;™;×,Ñ,°UÄ%Ç*Á*ÔMÐMr   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r   Úindicesz-tuple[torch.Tensor, ...] | list[torch.Tensor]Úvaluesztorch.Tensor | Boxesr  r   r   r   r   )r   s   "r   r   r¸   2  s2   € ÷ &ñ &à>ð&ð %ð&ð ð	&ð
 
ñ&r   c                ó  € V'       d   T MV P                  4       p\        V\        4      '       dº   VP                  P	                  WP
                  4       VP                  f,   VP                  P	                  WP                  4       4       V# VP                  P	                  WP                  4       VP                  P	                  \        V4      VP                  4       4        V# VP                  P	                  W4       V# )aï  Write box coordinates at selected tensor indices.

See the Convention block on :class:`~kornia.geometry.boxes.Boxes`.

This mirrors :meth:`torch.Tensor.index_put_` for the internal
quadrilateral tensor. It is useful when a subset of boxes in a batch
must be replaced while keeping the :class:`Boxes` wrapper and metadata.

Args:
    indices: Index tuple or list accepted by ``Tensor.index_put_``.
        The indices address entries in the stored tensor, commonly
        shaped ``(B, N, 4, 2)`` or ``(N, 4, 2)``.
    values: Replacement coordinates. If a :class:`Boxes` object is
        passed, its coordinates, filtering validity and list padding are copied. Raw tensor writes
        change only coordinates and preserve the existing filtering validity and list padding.
    inplace: If ``True``, update this object and return ``self``. If
        ``False``, clone the current data first and return a new
        :class:`Boxes` instance.

Returns:
    :class:`Boxes` containing the updated coordinates.
)r¦   ra   r   rÈ   Ú
index_put_rî   rÌ   rË   rõ   r^   r  )rÎ   r+  r,  r  r$  s   &&&& r   Ú	index_putÚBoxes.index_put2  s¼   € ÷8 ‰d 4§:¡:£<ˆÜ�fœe×$Ò$Ø�I‰I× Ñ  ¯+©+Ô6Ø�|‰|Ò#Ø—
‘
×%Ñ% g×/LÑ/LÓ/NÔOð ˆ
ð	 —
‘
×%Ñ% g¯}©}Ô=Ø—‘×'Ñ'¬°WÓ(=¸v×?VÑ?VÓ?XÕYð ˆ
ð �I‰I× Ñ  Ô1Øˆ
r   c               ó    € V ^8„  d   QhRRRR/# )r   r,  rL   r   r   )r   s   "r   r   r¸   Z  s   € ÷ ñ ¨|ð Àñ r   c                ó¤   € V P                   '       d
   VR,          # VP                  ^ 4      ^8w  d   \        RVP                  ^ 4       R24      hV# )aX  Shape a per-image ``(B, k)`` column so it broadcasts over ``self._data[..., i]``.

The batched container indexes as ``(B, N, 4)``, so the column needs one axis for the box
count. The unbatched ``(N, 4, 2)`` form carries a single implicit image and indexes as
``(N, 4)``, so its ``(1, k)`` column already broadcasts and must not gain that axis.
z]Unbatched (N, 4, 2) boxes carry a single image, so a per-image tensor must have one row. Got r6   ).NrS   )rÇ   ÚsizeÚRuntimeError)rÎ   r,  s   &&r   Ú_broadcast_over_verticesÚBoxes._broadcast_over_verticesZ  sY   € ð ××ÐØ˜,Õ'Ð'Ø�;‰;�q‹>˜QÔÜðØ—{‘{ 1“~Ð& að)óð ð ˆr   c               ó    € V ^8„  d   QhRRRR/# ©r   Úpadding_sizerL   r   r   r   )r   s   "r   r   r¸   j  s   € ÷ ñ  ð °ñ r   c                ó¸  € \        VP                  4      ^8X  d   VP                  ^4      ^8X  g   \        RVP                   R24      hVP	                  V P
                  P                  R7      pV P
                  R;;,          V P                  VR,          4      ,          uu&   V P
                  R;;,          V P                  VR,          4      ,          uu&   V # )aw  Pad every box in place.

See the Convention block on :class:`~kornia.geometry.boxes.Boxes`.

``padding_size`` is ordered as ``(left, right, top, bottom)``. Only
``left`` and ``top`` change the coordinate origin; this method returns
``self`` after adding those two values to every vertex. Both the batched
``(B, N, 4, 2)`` and the unbatched ``(N, 4, 2)`` container are
supported; the unbatched form carries a single image, so ``padding_size``
must have exactly one row.

Args:
    padding_size: Per-batch padding in ``(left, right, top, bottom)``
        order, shaped ``(B, 4)``. A single row broadcasts across the
        batch.

ú%Expected padding_size as (B, 4). Got r6   rQ   r}   ©.:Nr   Nr~   ©.ºr   r„   N©rÆ   r/   r3  r4  rÅ   rÈ   rP   r5  ©rÎ   r9  Úoffsets   && r   r7   Ú	Boxes.padj  ó¬   € ô$ �L×&Ñ&Ó'¨1Ô,°×1BÑ1BÀ1Ó1EÈÔ1JÜÐ!FÀ|×GYÑGYÐFZÐZ[Ð\Ó]Ð]Ø—‘¨¯
©
×(9Ñ(9�Ó:ˆØ�
‰
�6×˜d×;Ñ;¸FÀ7½OÓLÕLÓØ�
‰
�6×˜d×;Ñ;¸FÀ8Õ<LÓMÕMÓØˆr   c               ó    € V ^8„  d   QhRRRR/# r8  r   )r   s   "r   r   r¸   ƒ  s   € ÷ ñ  ,ð °5ñ r   c                ó¸  € \        VP                  4      ^8X  d   VP                  ^4      ^8X  g   \        RVP                   R24      hVP	                  V P
                  P                  R7      pV P
                  R;;,          V P                  VR,          4      ,          uu&   V P
                  R;;,          V P                  VR,          4      ,          uu&   V # )a�  Undo :meth:`pad` in place.

See the Convention block on :class:`~kornia.geometry.boxes.Boxes`.

``padding_size`` is ordered as ``(left, right, top, bottom)``. Only
``left`` and ``top`` change the coordinate origin; this method returns
``self`` after subtracting those two values from every vertex. Both the
batched ``(B, N, 4, 2)`` and the unbatched ``(N, 4, 2)`` container
are supported; the unbatched form carries a single image, so
``padding_size`` must have exactly one row.

Args:
    padding_size: Per-batch padding in ``(left, right, top, bottom)``
        order, shaped ``(B, 4)``. A single row broadcasts across the
        batch.

r;  r6   rQ   r}   r<  r~   r=  r?  r@  s   && r   ÚunpadÚBoxes.unpadƒ  rC  r   Nc               ó(   € V ^8„  d   QhRRRRRRRR/# )r   Útopleftrã   Úbotrightr  r   r   r   r   )r   s   "r   r   r¸   œ  s2   € ÷ 9ñ 9à'ð9ð )ð9ð ð	9ð
 
ñ9r   c                óÌ  € \        V\        P                  4      '       d!   \        V\        P                  4      '       g9   \        R\	        V4      P
                   R\	        V4      P
                   R24      hV'       d   V P                  MV P                  P                  4       pV P                  VR,          4      pV P                  VR,          4      pV P                  VR,          4      pV P                  VR,          4      pVR,          VR,          r©\        P                  ! W•8  VP                  V	4      V	4      p	\        P                  ! W¦8  VP                  V
4      V
4      p
\        P                  ! W—8„  VP                  V	4      V	4      p	\        P                  ! W¨8„  VP                  V
4      V
4      p
W”R&   W¤R&   V'       d   V # V P                  4       pWKn        V# )a  Clamp every box vertex inside per-image coordinate limits.

See the Convention block on :class:`~kornia.geometry.boxes.Boxes`.

Convention:
    Bounds are tensors with one ``(x, y)`` pair per batch element, or a single row that broadcasts (an
    unbatched container needs exactly one row). Every vertex is clamped independently, so a box wholly
    outside the bounds collapses onto the boundary instead of being removed.

Args:
    topleft: Required tensor of shape ``(B, 2)`` containing the minimum
        ``x`` and ``y`` coordinate allowed for each batch item. A single
        row broadcasts across the batch.
    botright: Required tensor of shape ``(B, 2)`` containing the maximum
        ``x`` and ``y`` coordinate allowed for each batch item. A single
        row broadcasts across the batch.
    inplace: If ``True``, clamp this object in place. Otherwise, return
        a new :class:`Boxes` object with clamped data.

Returns:
    :class:`Boxes` whose vertex coordinates are restricted to the
    provided bounds.
z\`Boxes.clamp` accepts `topleft` and `botright` as `(B, 2)` torch.Tensor bounds; got topleft=z and botright=r6   r<  ).ºr   NNr}   r~   )ra   r    rb   rC   re   Ú__name__rÈ   r¦   r5  ÚwhereÚ	expand_as)rÎ   rI  rJ  r  rÈ   Ú	topleft_xÚ	topleft_yÚ
botright_xÚ
botright_yÚcoord_xÚcoord_yr$  s   &&&&        r   ÚclampÚBoxes.clampœ  s‘  € ô: ˜7¤E§L¡L×1Ò1´jÀÌ5Ï<É<×6XÒ6XÜ%ðÜ# G›}×5Ñ5Ð6°nÄTÈ(Ã^×E\ÑE\ÐD]Ð]^ð`óð ÷ &�—
’
¨4¯:©:×+;Ñ+;Ó+=ˆð ×1Ñ1°'¸'Õ2BÓCˆ	Ø×1Ñ1°'¸'Õ2BÓCˆ	Ø×2Ñ2°8¸GÕ3DÓEˆ
Ø×2Ñ2°8¸GÕ3DÓEˆ
à  �=¨%°­-�Ü—+’+˜gÑ1°9×3FÑ3FÀwÓ3OÐQXÓYˆÜ—+’+˜gÑ1°9×3FÑ3FÀwÓ3OÐQXÓYˆÜ—+’+˜gÑ2°J×4HÑ4HÈÓ4QÐSZÓ[ˆÜ—+’+˜gÑ2°J×4HÑ4HÈÓ4QÐSZÓ[ˆØˆf‰Øˆf‰ßØˆKà�j‰j‹lˆØŒ	Øˆ
r   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Úcorrespondence_preserver   r  r   r   r   )r   s   "r   r   r¸   ×  s'   € ÷ Fñ F¨Dð FÀ4ð FÐTYñ Fr   c                ó4   € \        RRRR4       \        R4      h)a:  Deprecated since 0.9.1 and never implemented: raises ``NotImplementedError``.

See the Convention block on :class:`~kornia.geometry.boxes.Boxes`.

Args:
    correspondence_preserve: Reserved for a future implementation.
    inplace: Reserved for a future implementation.

Raises:
    NotImplementedError: Always.

z
Boxes.trimNz0.9.1zKIt has never been implemented and raises NotImplementedError (kornia#4017).z `Boxes.trim` is not implemented.)r   rC   )rÎ   rY  r  s   &&&r   ÚtrimÚ
Boxes.trim×  s$   € ô 	"Ø˜$ Ð)vô	
ô "Ð"DÓEÐEr   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   Úmin_areazOptional[float]Úmax_arear  r   r   r   r   )r   s   "r   r   r¸   é  s,   € ÷ %ñ %Ø'ð%Ø:Ið%Ø[_ð%à	ñ%r   c                óº  € V P                  4       pVP                  V P                  P                  4      p\        P
                  ! V\        P                  R7      pVe   WeV8  ( ,          pVe   WeV8„  ( ,          pV'       d   T MV P                  4       pV;P                  V,          un        Vf   Ve%   VP                  P                  VR,          ( R4       V# )aþ  Zero boxes whose polygon area is outside the requested range.

See the Convention block on :class:`~kornia.geometry.boxes.Boxes`.

The box area is computed from its four vertices. Boxes smaller than
``min_area`` or larger than ``max_area`` are not dropped from the
tensor; their coordinates are replaced with zeros so the original batch
and box dimensions stay unchanged. See :meth:`compute_area` for the
area convention used by the thresholds. Filtered boxes export as exact zeros in every
mode and draw no mask pixels, including after subsequent coordinate transforms.

Args:
    min_area: Optional lower inclusive area threshold. Boxes with area
        below this value are zeroed.
    max_area: Optional upper inclusive area threshold. Boxes with area
        above this value are zeroed.
    inplace: If ``True``, update this object in place. Otherwise,
        return a filtered clone.

Returns:
    :class:`Boxes` with the same shape as the input container and
    out-of-range boxes replaced by zero coordinates.
r&   ç        r  )
Úcompute_arearl   rË   r/   r    Ú	ones_liker   r¦   rÈ   Úmasked_fill_)rÎ   r^  r_  r  ÚareaÚ	area_flatÚkeepr$  s   &&&&    r   Úfilter_boxes_by_areaÚBoxes.filter_boxes_by_areaé  s³   € ð4 × Ñ Ó"ˆØ—L‘L §¡×!2Ñ!2Ó3ˆ	Ü�Š˜y´·
±
Ô;ˆØÒØ (Ñ*Ð+Õ+ˆDØÒØ (Ñ*Ð+Õ+ˆDß‰d 4§:¡:£<ˆØ�
Š
�dÕ�
ØÒ 8Ò#7Ø�I‰I×"Ñ" D¨Õ$9Ð#9¸3Ô?Øˆ
r   c               ó   € V ^8„  d   QhRR/# ró   r   )r   s   "r   r   r¸     s   € ÷ Qñ Q˜lñ Qr   c                ór  € V P                   P                  ^8X  d   V P                   P                  ^ ^4      MV P                   pVP                  ^RR7      p\        P
                  ! VR,          VR,          ,
          VR,          VR,          ,
          4      p\        P                  ! V^RR7      w  rE\        P                  ! V^VP                  R	4      P                  R	R	^4      4      pVR,          VR,          r‡R\        P                  ! \        P                  ! V\        P                  ! V^^4      ,          V\        P                  ! V^^4      ,          ,
          ^R7      4      ,          p	V P                   P                  ^8X  d-   V	P                  V P                   P                  R,          4      # T	# )
aÿ  Compute polygon area with the shoelace formula.

See the Convention block on :class:`~kornia.geometry.boxes.Boxes`.

Convention:
    Vertices are sorted by angle about their centroid, so a convex quadrilateral is assumed.

.. warning::
    On the stored inclusive vertices an axis-aligned box gives ``(width - 1) * (height - 1)``, not the
    ``width * height`` of :meth:`get_boxes_shape`: `#4010 <https://github.com/kornia/kornia/issues/4010>`_.

Returns:
    Area for each box, shaped ``(N,)`` or ``(B, N)``.
T)r0   Úkeepdim)r0   Ú
descendingg      à?r¯   ºNr   Nr~   r}   rk   )rÈ   rm   ÚflattenÚmeanr    Úatan2Úsortr   rn   ÚexpandÚabsrù   ÚrollÚviewr/   )
rÎ   ÚcoordsÚcentroidÚanglesÚ_Úclockwise_indicesÚordered_cornersÚxÚyre  s
   &         r   rb  ÚBoxes.compute_area  sB  € ð .2¯Z©Z¯_©_ÀÔ-A�—‘×#Ñ# A qÔ)ÀtÇzÁzˆà—;‘; 1¨d�;Ó3ˆä—’˜V F�^¨h°vÕ.>Õ>ÀÀvÅÐQYÐZ`ÕQaÕ@aÓbˆä$Ÿzšz¨&°aÀDÔIÑˆäŸ,š, v¨qÐ2C×2MÑ2MÈbÓ2Q×2XÑ2XÐY[Ð]_ÐabÓ2cÓdˆØ˜vÕ&¨¸Õ(?ˆ1à”U—Y’YœuŸyšy¨!¬e¯jªj¸¸A¸qÓ.AÕ*AÀaÌ%Ï*Ê*ÐUVÐXYÐ[\ÓJ]ÕF]Õ)^ÐdeÔfÓgÕgˆØ26·*±*·/±/ÀQÔ2Fˆt�y‰y˜Ÿ™×)Ñ)¨"Õ-Ó.ÐPÈDÐPr   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r   r)   ztorch.Tensor | listr—   r+   r˜   r   r   r   r   )r   s   "r   r   r¸   .  s+   € ÷ =0ñ =0Ð 3ð =0¸3ð =0ÐY]ð =0Ðinñ =0r   c                ó(  € \        V\        P                  4      '       d   \        WVR7      pMÖ\	        V4      ^ 8X  dc   VP                  4       P                  R4      '       d   \        P                  ! ^ ^^4      M\        P                  ! ^ ^4      p\        WRVR7      pMd\        V^ ,          \        P                  4      '       d   V Uu. uF  p\        WbV4      NK  	  ppM!\        \        P                  ! V4      W#R7      pV ! VRV4      # u upi )aˆ  Create :class:`Boxes` from boxes stored in another format.

See the Convention block on :class:`~kornia.geometry.boxes.Boxes`.

Args:
    boxes: 2D boxes, shape of ``(N, 4)``, ``(B, N, 4)``, ``(N, 4, 2)`` or
        ``(B, N, 4, 2)``, a nested numeric list with one of those shapes, or a list of
        ``(N, 4)`` or ``(N, 4, 2)`` tensors matching ``mode``. Integer input is cast to ``float32``,
        or ``float64`` when that is the default dtype. Floating-point input keeps its dtype.
    mode: The format in which the boxes are provided:

        * 'xyxy': ``xmin, ymin, xmax, ymax`` with exclusive extent. With shape ``(N, 4)``,
          ``(B, N, 4)``.
        * 'xyxy_plus': ``xmin, ymin, xmax, ymax`` with inclusive extent. With shape ``(N, 4)``,
          ``(B, N, 4)``.
        * 'xywh': ``xmin, ymin, width, height`` with exclusive extent. With shape ``(N, 4)``,
          ``(B, N, 4)``.
        * 'vertices': boxes are defined by their vertices points in the following ``clockwise`` order:
          *top-left, top-right, bottom-right, bottom-left*. Vertices coordinates are in (x,y) order. This is
          the exclusive input form. With shape ``(N, 4, 2)``, ``(B, N, 4, 2)``.
        * 'vertices_plus': the inclusive stored vertex form. With shape ``(N, 4, 2)``,
          ``(B, N, 4, 2)``.

    validate_boxes: Reject a non-finite coordinate in every mode: ``ValueError`` for the ``'xy*'`` modes,
        which also reject non-positive extents in each mode's convention, and ``RuntimeError`` from
        ``torch._assert_async`` for the vertex modes, which take no extent or shape check.
        The ``'xy*'`` checks read the data, so graph capture (``torch.compile``, ``torch.export``) skips
        them.

Returns:
    :class:`Boxes` containing the converted inclusive vertex representation.

Examples:
    >>> boxes_xyxy = torch.as_tensor([[0, 3, 1, 4], [5, 1, 8, 4]])
    >>> boxes = Boxes.from_tensor(boxes_xyxy, mode='xyxy')
    >>> boxes.data  # (2, 4, 2)
    tensor([[[0., 3.],
             [0., 3.],
             [0., 3.],
             [0., 3.]],
    <BLANKLINE>
            [[5., 1.],
             [7., 1.],
             [7., 3.],
             [5., 3.]]])

©r—   r˜   rš   F)	ra   r    rb   rª   rÆ   r£   r¤   r…   rT   )Úclsr)   r—   r˜   r©   Úemptyr3   s   &&&&   r   Úfrom_tensorÚBoxes.from_tensor-  sØ   € ôd �eœUŸ\™\×*Ò*Ü5°eÐWeÔf‰NÜ�‹Z˜1Œ_à,0¯J©J«L×,CÑ,CÀJ×,OÒ,O”E—K’K  1 aÔ(ÔUZ×U`ÒU`ÐabÐdeÓUfˆEÜ5°eÐWeÔf‰NÜ˜˜a�¤%§,¡,×/Ò/Ù]bÓcÑ]bÐVYÔ6°sÀ.ÖQÑ]bˆNÐcˆNô 6´e·o²oÀeÓ6LÐSWÔwˆNá�> 5¨$Ó/Ð/ùò ds   ÃDc               ó$   € V ^8„  d   QhRRRRRR/# ©r   r—   zOptional[str]r  r   r   r¶   r   )r   s   "r   r   r¸   m  s)   € ÷ ]?ñ ]?Ø!ð]?Ø>Bð]?à	*ñ]?r   c                ó  € V P                   '       d   V P                  MV P                  P                  ^ 4      p\        P                  ! VP                  RR7      VP                  RR7      .RR7      P                  VP                  ^ ,          VP                  ^,          ^4      pVf   V P                  pVP                  4       pVR	9   d   MYVR
9   dE   VR,          VR,          ,
          ^,           VR,          VR,          ,
          ^,           reWdR&   WTR&   M\        RV 24      hVR9   d8   \        P                  ! . ROVP                  VP                  R7      pWG,           pVP                  R4      '       d+   \!        VR,          VR,          VR,          VR,          4      pV P                   '       d   V P"                  MV P"                  P                  ^ 4      pVP%                  VP                  RVP&                  VP&                  ,
          ,          ,           4      pVP)                  V( R4      pV P*                  e¥   V P                   '       d“   V'       g‹   V P*                  ( p	V	P-                  RR7      w  r«V\/        W¤P                  4      \/        W´P                  4      3,          p\1        VP3                  V	P5                  RR7      P7                  4       4      4      # V P                   '       d   V# VP9                  ^ 4      # )a-  Cast :class:`Boxes` to a tensor.

See the Convention block on :class:`~kornia.geometry.boxes.Boxes`.

``mode`` selects the output representation. ``'xyxy'``, ``'xywh'``, and ``'vertices'`` are exclusive
exports; the ``'_plus'`` variants are inclusive. Every mode exports the axis-aligned bounds of the
stored vertices, reduced with ``amin``/``amax``, so the export is lossy for rotated boxes:
``to_tensor('vertices_plus')`` does not return :attr:`data` unchanged after a :meth:`transform_boxes`
call that rotates, shears, or otherwise reorders the vertices. A quarter turn keeps the box
axis-aligned and still yields an export that differs from :attr:`data`, because the reduction
re-canonicalizes the vertex order.

.. warning::
    Before torch 2.10, ``torch.compile(..., fullgraph=True)`` around the trimmed export of boxes built from a
    list raises, because that export reads its rows with ``nonzero``, whose output size depends on the data.
    Setting ``torch._dynamo.config.capture_dynamic_output_shape_ops``, as the error suggests, still raises.
    Setting ``capture_scalar_outputs`` as well makes it compile, and on torch 2.5 and 2.6 it then returns wrong
    rows with no error, from a miscompile of ``nonzero`` in torch. ``as_padded_sequence=True`` and default
    ``torch.compile`` return the right rows on every one of these versions.

Args:
    mode: the output box format, or ``None`` to reuse :attr:`mode`. That attribute depends on the
        construction path: the constructor defaults to ``'vertices_plus'``, while :meth:`from_tensor`
        records the mode its input was given in. It could be:

        * 'xyxy': ``xmin, ymin, xmax, ymax`` with exclusive extent.
        * 'xyxy_plus': ``xmin, ymin, xmax, ymax`` with inclusive extent.
        * 'xywh': ``xmin, ymin, width, height`` with exclusive extent.
        * 'vertices': boxes are defined by their vertices points in the following ``clockwise`` order:
          *top-left, top-right, bottom-right, bottom-left*. Vertices coordinates are in (x,y) order. This is
          the exclusive export form.
        * 'vertices_plus': the inclusive stored vertex form.
    as_padded_sequence: If this object was created from a list, return its padded tensor rather than a list
        of tensors trimmed to their original lengths. The padded values follow the selected output mode.
        Batch slicing, index tensors, and boolean masks keep the list export. A selection that returns an
        unbatched object, such as an integer or scalar tensor index, exports all its rows, padding included,
        as one tensor.

Returns:
    Boxes tensor in the ``mode`` format, or a list of tensors when the object was created from a list and
    ``as_padded_sequence=False``. The tensor shape depends on the ``mode`` value:

        * 'vertices' or 'vertices_plus': ``(N, 4, 2)`` or ``(B, N, 4, 2)``.
        * Any other value: ``(N, 4)`` or ``(B, N, 4)``.

Examples:
    >>> boxes_xyxy = torch.as_tensor([[0, 3, 1, 4], [5, 1, 8, 4]])
    >>> boxes = Boxes.from_tensor(boxes_xyxy)
    >>> assert (boxes_xyxy == boxes.to_tensor(mode='xyxy')).all()

r¯   rš   rœ   rO   ra  T)Úas_tupler.   )rž   rŸ   )r    rš   r�   r¡   r~   r¢   r}   )rž   rš   )r9   r9   r   r   )r   rk   )rÇ   rÈ   rn   r    rŽ   ÚaminÚamaxrv  r/   r—   r£   ro   rT   rP   r   r¤   r‡   rË   rl   rm   Úmasked_fillrÌ   Únonzeror   rd   Úsplitrù   r‘   r§   )rÎ   r—   r  Úbatched_boxesr)   r{   rz   rA  r  rg  ÚsamplesÚrowsÚkepts   &&&          r   r  ÚBoxes.to_tensorm  se  € ðl '+×&6×&6Ð&6˜Ÿ
š
¸D¿J¹J×<PÑ<PÐQRÓ<Sˆô
 —’˜]×/Ñ/°BÐ/Ó7¸×9KÑ9KÐPRÐ9KÓ9SÐTÐZ\Ô]×bÑbØ×Ñ Õ" M×$7Ñ$7¸Õ$:¸Aó
ˆð Š<Ø—9‘9ˆDà�z‰z‹|ˆàÐ(Ô(ØØÐ:Ô:Ø! &�M¨E°&­MÕ9¸AÕ=¸uÀV½}ÈuÐU[Í}Õ?\Ð_`Õ?`�EØ!�&‰MØ"�&ŠMä˜}¨T¨FÐ3Ó4Ð4àÐ'Ô'Ü—_’_¢\¸%¿,¹,ÈeÏkÉkÔZˆFØ•NˆEà�?‰?˜:×&Ò&Ü& u¨V¥}°e¸FµmÀUÈ6Å]ÐTYÐZ`ÕTaÓbˆEà#×/×/Ð/�—’°T·[±[×5JÑ5JÈ1Ó5MˆØ—‘˜eŸk™k¨D°E·J±JÀÇÁÕ4KÕ,LÕLÓMˆØ×!Ñ! 5 &¨#Ó.ˆà�=‰=Ò$¨×)9×)9Ð)9×BTØ—M‘M�>ˆDØ ŸL™L°$˜LÓ7‰MˆGØÔ/°¿¹ÓFÔH^Ð_c×eqÑeqÓHrÐrÕsˆDÜ˜Ÿ
™
 4§8¡8° 8Ó#3×#:Ñ#:Ó#<Ó=Ó>Ð>Ø×(×(Ð(ˆuÐ>¨e¯m©m¸AÓ.>Ð>r   c               ó$   € V ^8„  d   QhRRRRRR/# ©r   r{   rK   rz   r   rL   r   )r   s   "r   r   r¸   Ì  s&   € ÷ j&ñ j&˜cð j&¨#ð j&°,ñ j&r   c                ó"  € V P                   P                  '       d   \        R4      hV P                  pV P                  pV P
                  p\        \        P                  V P                  RRR7      4      pVR,          P                  ^ V4       VR	,          P                  ^ V4       V P                  e.   VP                  \        V P                  V4      R
,          ^ 4       VP                  R8w  Eds   \        4       '       Egb   \        P                   P#                  4       '       Eg=   V P                  '       dh   \        P$                  ! V P                   P&                  ^ ,          V P                   P&                  ^,          W3V P                  V P
                  R7      pMJ\        P$                  ! V P                   P&                  ^ ,          W3V P                  V P
                  R7      p\)        VP+                  ^ R4      VP-                  R^4      P/                  4       P1                  4       4       F+  w  r‰^W‰^,          V	^,          1V	^ ,          V	^,          13&   K-  	  V# V'       d(   V P&                  ^ ,          V P&                  ^,          W3MV P&                  ^ ,          W3p
VP-                  R^4      P/                  4       P3                  4       pVR,          VR,          VR,          VR,          3w  rÍrïVP5                  ^ V4      pVP5                  ^ V4      pVP5                  ^ V4      pVP5                  ^ V4      p\        P6                  ! WR7      p\        P6                  ! W%R7      pVR,          VR,          8¬  VR,          VR,          8  ,          pVR,          VR,          8¬  VR,          VR,          8  ,          pVP9                  ^4      VP9                  ^4      ,          P;                  V4      pVP,                  ! V
!  # )a«  Convert 2D boxes to masks. Covered area is 1 and the remaining is 0.

See the Convention block on :class:`~kornia.geometry.boxes.Boxes`.

Convention:
    The size is ``(height, width)`` and the mask ``(N, height, width)`` or
    ``(B, N, height, width)`` in the box dtype. The exclusive ``'xyxy'`` export is clamped to the
    image, rounded to the nearest integer and filled over ``[xmin, xmax)``, ``[ymin, ymax)``. Padding
    entries of a list-backed object give empty masks. A box tensor that requires grad raises
    ``RuntimeError``.

.. warning::
    :func:`~kornia.geometry.bbox.bbox_to_mask` takes ``(height, width)`` through its ``size`` argument,
    like this method (`#4014 <https://github.com/kornia/kornia/issues/4014>`_); its deprecated
    ``width, height`` form takes the opposite order. It also does not round, so a fractional box can
    fill a different area (`#4015 <https://github.com/kornia/kornia/issues/4015>`_).

Args:
    height: height of the masked image/images.
    width: width of the masked image/images.

Returns:
    the output mask tensor, shape of ``(N, height, width)`` or ``(B, N, height, width)`` and dtype of
    :func:`Boxes.dtype` (it can be any floating point dtype).

Note:
    It is currently non-differentiable.

Examples:
    >>> boxes = Boxes(torch.tensor([[  # Equivalent to Boxes.from_tensor([[1, 1, 4, 3]], mode='xyxy_plus')
    ...        [1., 1.],
    ...        [4., 1.],
    ...        [4., 3.],
    ...        [1., 3.],
    ...   ]]))  # 1x4x2
    >>> boxes.to_mask(5, 5)
    tensor([[[0., 0., 0., 0., 0.],
             [0., 1., 1., 1., 1.],
             [0., 1., 1., 1., 1.],
             [0., 1., 1., 1., 1.],
             [0., 0., 0., 0., 0.]]])

úcBoxes.to_tensor isn't differentiable. Please, create boxes from tensors with `requires_grad=False`.rž   Tr  Úcuda©r   rP   rQ   ).:NNr   ).:r   Nr   ).Nrj   rk   )rS   r9   )rS   r   )rS   r   )rS   r„   ©NrS   rR   )rÈ   Úrequires_gradr4  rÇ   r   rP   r   r    rb   r  Úclamp_rÌ   rd  r   re   r   ÚjitÚ
is_tracingr…   r/   Úzipro  rv  ÚroundrK   rU   rV  rV   rn   rÅ   )rÎ   r{   rz   Ú
is_batchedr   rP   Úclipped_boxes_xyxyÚmaskÚmask_channelÚbox_xyxyÚ	out_shaperž   Úx1Úy1Úx2Úy2ÚysÚxsÚy_maskÚx_maskÚmaskss   &&&                  r   Úto_maskÚBoxes.to_maskÌ  s7  € ðX �:‰:×#×#Ð#ÜØuóð ð ×%Ñ%ˆ
Ø—
‘
ˆØ—‘ˆô "¤%§,¡,°·±¸vÐZ^°Ó0_Ó`ÐØ˜8Õ$×+Ñ+¨A¨uÔ5Ø˜9Õ%×,Ñ,¨Q°Ô7Ø�=‰=Ò$à×+Ñ+Ô,BÀ4Ç=Á=ÐRXÓ,YÐZcÕ,dÐfgÔhð �;‰;˜&Õ ¬¯«ÄÇ	Á	×@TÑ@T×@VÓ@VØ××ÐÜ—{’{Ø—Z‘Z×%Ñ% aÕ(¨$¯*©*×*:Ñ*:¸1Õ*=¸vÐMÐUY×U_ÑU_Ðhl×hsÑhsô‘ô —{’{ D§J¡J×$4Ñ$4°QÕ$7¸Ð#GÈtÏzÉzÐbf×bmÑbmÔn�ô
 +.¨d¯l©l¸1¸bÓ.AÐCU×CZÑCZÐ[]Ð_`ÓCa×CgÑCgÓCi×CmÑCmÓCoÖ*pÑ&�àUV� a�[¨8°A­;Ð6¸À½ÀhÈqÅkÐ8QÐQÓRñ +qð ˆK÷ FP�T—Z‘Z •] D§J¡J¨q¥M°6ÑAÐVZ×V`ÑV`ÐabÕVcÐekÐUsˆ	à!×&Ñ& r¨1Ó-×3Ñ3Ó5×:Ñ:Ó<ˆà˜d� T¨$¥Z°°dµ¸TÀ$½ZÐG‰ˆ�Ø�X‰X�a˜ÓˆØ�X‰X�a˜ÓˆØ�X‰X�a˜Ó ˆØ�X‰X�a˜Ó ˆä�\Š\˜&Ô0ˆÜ�\Š\˜%Ô/ˆà�W•+  G¥Ñ,°°Gµ¸rÀ'½{Ñ1JÕKˆØ�W•+  G¥Ñ,°°Gµ¸rÀ'½{Ñ1JÕKˆà×!Ñ! !Ó$ v×'7Ñ'7¸Ó':Õ:×>Ñ>¸uÓEˆØ�zŠz˜9Ñ%Ð%r   c               ó$   € V ^8„  d   QhRRRRRR/# )r   rg   rL   r  r   r   r   r   )r   s   "r   r   r¸   8  s!   € ÷ ñ  ð ¸ð Èñ r   c                ó&  € ^VP                   u;8:  d   ^8:  d   M MVP                  RR R8w  d   \        RVP                   R24      h\        V P                  V4      pV'       d   V P                  V4       V # V P                  4       pW4n        V# )a*  Apply a transformation matrix to the 2D boxes.

See the Convention block on :class:`~kornia.geometry.boxes.Boxes`.

Args:
    M: The transformation matrix to be applied, shape of ``(3, 3)`` or ``(B, 3, 3)``.
    inplace: do transform in-place and return self.

Returns:
    The transformed boxes.

NzAThe transformation matrix shape must be (3, 3) or (B, 3, 3). Got r6   r.   )r„   r„   )rm   r/   ro   rv   rÈ   rð   r¦   )rÎ   rg   r  ru   r$  s   &&&  r   Útransform_boxesÚBoxes.transform_boxes8  s�   € ð �A—F‘FÖ˜a× 1§7¡7¨2¨3 <°6Ô#9ÜÐ`Ðab×ahÑahÐ`iÐijÐkÓlÐlä,¨T¯Z©Z¸Ó;ÐßØ×ÑÐ/Ô0ØˆKà�j‰j‹lˆØ%Œ	Øˆ
r   c               ó    € V ^8„  d   QhRRRR/# )r   rg   rL   r   r   r   )r   s   "r   r   r¸   Q  s   € ÷ 5ñ 5 ,ð 5°5ñ 5r   c                ó(   € V P                  VRR7      # )az  Apply :meth:`transform_boxes` in place and return ``self``.

See the Convention block on :class:`~kornia.geometry.boxes.Boxes`.

Convention:
    The internal tensor is rebound, not written: a tensor obtained from :attr:`data` before the call
    keeps the old coordinates (an empty container keeps its tensor).

Returns:
    This :class:`Boxes` object after the transformation.
T©r  ©rµ  ©rÎ   rg   s   &&r   Útransform_boxes_ÚBoxes.transform_boxes_Q  ó   € ð ×#Ñ# A¨tÐ#Ó4Ð4r   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r   r3  rL   r*   r+   r  r   r   r   r   )r   s   "r   r   r¸   _  s)   € ÷ 8ñ 8˜lð 8°Cð 8È4ð 8Ð\añ 8r   c                ót   € VR8w  d   \        RV: R24      h\        ^V4      pWR&   V P                  WCR7      # )aÐ  Translate boxes by the provided size.

See the Convention block on :class:`~kornia.geometry.boxes.Boxes`.

``size`` supplies one ``(x, y)`` translation per batch item. Only the
``"warp"`` method is supported; any other method raises
:class:`NotImplementedError`.

Args:
    size: translate size for x, y direction, shape of ``(B, 2)``.
    method: only "warp" is supported.
    inplace: do transform in-place and return self.

Returns:
    The transformed boxes.

Úwarpz6`Boxes.translate` accepts `method='warp'`; got method=r6   r¹  )rS   rn  r   )rC   r
   rµ  )rÎ   r3  r*   r  rg   s   &&&& r   Ú	translateÚBoxes.translate_  sK   € ð$ �VÔÜ%Ð(^Ð_eÑ^hÐhiÐ&jÓkÐkä" 1 dÓ+ˆØˆ(‰Ø×#Ñ# AÐ#Ó7Ð7r   c               ó   € V ^8„  d   QhRR/# ró   r   )r   s   "r   r   r¸   y  s   € ÷ 	ñ 	�lñ 	r   c                ó   € V P                   # )a(  Return the raw quadrilateral coordinate tensor.

Returns:
    Tensor storing four vertices per box in ``(x, y)`` order. The
    common shapes are ``(N, 4, 2)`` for unbatched boxes and
    ``(B, N, 4, 2)`` for batched boxes, where :math:`B` is batch
    size and :math:`N` is the number of boxes.
©rÈ   rê   s   &r   rî   Ú
Boxes.datax  s   € ð �z‰zÐr   c               ó   € V ^8„  d   QhRR/# ©r   r   r+   r   )r   s   "r   r   r¸   …  ó   € ÷ ñ �cñ r   c                ó   € V P                   # )zØReturn the box format remembered by this container.

Returns:
    Mode string used as the default by :meth:`to_tensor`, such as
    ``"xyxy"``, ``"xyxy_plus"``, ``"xywh"``, ``"vertices"`` or
    ``"vertices_plus"``.
©rÉ   rê   s   &r   r—   Ú
Boxes.mode„  ó   € ð �z‰zÐr   c               ó   € V ^8„  d   QhRR/# ©r   r   ztorch.devicer   )r   s   "r   r   r¸   �  ó   € ÷ !ñ !˜ñ !r   c                ó.   € V P                   P                  # ©zReturns boxes device.©rÈ   rP   rê   s   &r   rP   ÚBoxes.device�  ó   € ð �z‰z× Ñ Ð r   c               ó   € V ^8„  d   QhRR/# ©r   r   r   r   )r   s   "r   r   r¸   •  ó   € ÷  ñ  �{ñ  r   c                ó.   € V P                   P                  # ©zReturns boxes dtype.©rÈ   r   rê   s   &r   r   ÚBoxes.dtype”  ó   € ð �z‰z×ÑÐr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   rP   úOptional[torch.device]r   úOptional[torch.dtype]r   r   r   )r   s   "r   r   r¸   ™  s$   € ÷ 
ñ 
Ð/ð 
Ð?Tð 
Ð`eñ 
r   c                óœ   € Ve   \        V4      '       g   \        R4      hV P                  V P                  P	                  WR7      4       V # ©a  Move or cast the stored tensor and return ``self``, as :meth:`torch.nn.Module.to` does.

The tensor is rebound, not converted in place: one obtained from :attr:`data` before the call keeps its device
and dtype. A ``dtype`` that is not floating point raises ``ValueError``.
zBoxes must be in floating pointrO   )r'   ro   rð   rÈ   rÅ   ©rÎ   rP   r   s   &&&r   rÅ   ÚBoxes.to™  sC   € ð ÒÔ%=¸e×%DÒ%DÜÐ>Ó?Ð?Ø×Ñ˜$Ÿ*™*Ÿ-™-¨v˜-ÓCÔDØˆr   c               ó   € V ^8„  d   QhRR/# )r   r   r   r   )r   s   "r   r   r¸   ¥  s   € ÷ ñ �uñ r   c                ó:  € \        V 4      ! V P                  P                  4       R4      pV P                  Vn        V P                  f   RMV P                  P                  4       Vn        V P
                  P                  4       Vn        V P                  Vn        V# )zÍCreate an independent copy of the box container.

Returns:
    New :class:`Boxes` object with cloned tensor storage. Metadata such
    as the current mode, list padding, and batched flag is
    preserved.
FN)re   rÈ   r¦   rÉ   rÌ   rË   rÇ   ©rÎ   r$  s   & r   r¦   ÚBoxes.clone¥  sq   € ô �4Œj˜Ÿ™×)Ñ)Ó+¨UÓ3ˆØ—J‘JˆŒ	Ø#Ÿ}™}Ò4‘t¸$¿-¹-×:MÑ:MÓ:OˆŒØ—[‘[×&Ñ&Ó(ˆŒ
Ø×*Ñ*ˆŒØˆ
r   c               ó    € V ^8„  d   QhRRRR/# )r   r   r   r   r   r   )r   s   "r   r   r¸   ´  s   € ÷ 
ñ 
˜+ð 
¨%ñ 
r   c                óZ   € V P                  V P                  P                  V4      4       V # )a  Cast the stored box coordinates to a new dtype.

Args:
    dtype: Target dtype for the coordinate tensor. Unlike :meth:`to`, an integer dtype is not rejected.

Returns:
    ``self``, rebound to the converted tensor; the tensor it wrapped before is not modified.
)rð   rÈ   re   )rÎ   r   s   &&r   re   Ú
Boxes.type´  s$   € ð 	×Ñ˜$Ÿ*™*Ÿ/™/¨%Ó0Ô1Øˆr   )rÈ   rÇ   rÉ   rÌ   rË   )Tr�   ©F)NNF)FF©rž   Tr  )rÁ  F©NN)*rM  Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rÒ   rÞ   rÍ   rë   rð   rõ   Úpropertyr×   r  r  r/   r  r%  r  r/  r5  r7   rF  rV  r[  rh  rb  Úclassmethodr…  r  r±  rµ  r¼  rÂ  rî   r—   rP   r   rÅ   r¦   re   Ú__static_attributes__r   r   r   r   r   õ   s0  † ñg÷R6Mõp	0õ õ2õ!õXð ô2ó ð2õõ"ð ô
ó ð
õ÷(-õ^N÷&õPõ õ2÷29÷vF÷$%õNQð: ö=0ó ð=0÷~]?õ~j&÷Xõ25÷8ð2 ô	ó ð	ð ôó ðð ô!ó ð!ð ô ó ð ÷
õ÷
ñ 
r   c                  ó°   a € ] tR tRt$ RtR]R&   R R lt]RR R ll4       tR	 R
 lt	R R lt
RR V 3R llltR R ltR V 3R lltR V 3R lltRtV ;t# )r   iÁ  a}  Store the 2D boxes of (B, T) video frames, restoring the temporal axis on export.

``boxes = VideoBoxes.from_tensor(corners)`` takes inclusive ``'vertices_plus'`` corners ``(B, T, N, 4, 2)``, with
no mode or conversion, and stores them flattened as ``(B * T, N, 4, 2)``, so the methods it inherits from
:class:`Boxes` act on every frame; ``boxes.to_tensor('xyxy')`` exports ``(B, T, N, 4)``, with the temporal axis
restored, and ``boxes.to_tensor()`` the ``(B, T, N, 4, 2)`` corners.
:class:`~kornia.augmentation.container.AugmentationSequential` stores the boxes of a pipeline that contains a
:class:`~kornia.augmentation.container.VideoSequential` in this class. Convert boxes in another format to corners
first: ``Boxes.from_tensor(xyxy.flatten(0, 1)).data.unflatten(0, (B, T))`` converts ``(B, T, N, 4)`` ``xyxy``
boxes. For the boxes of single images, use :class:`Boxes`.

See the Convention block on :class:`~kornia.geometry.boxes.Boxes`.

Convention:
    - :meth:`from_tensor` stores ``(B, T, N, 4, 2)`` input unchanged as ``(B * T, N, 4, 2)``
      ``'vertices_plus'`` data, with no mode or conversion; integer input is cast to ``float32``,
      or ``float64`` when that is the default dtype. Another shape or a list raises ``ValueError``.
      ``validate_boxes=True`` rejects a non-finite coordinate as
      :meth:`Boxes.from_tensor` does for ``'vertices_plus'``.
    - :meth:`to_tensor` accepts every :class:`Boxes` mode and restores the temporal axis
      (``to_tensor('xyxy')`` is ``(B, T, N, 4)``).
    - :meth:`compute_area` returns ``(B, T, N)`` areas, and :meth:`to_mask` returns
      ``(B, T, N, height, width)`` masks. :attr:`~Boxes.shape` and :attr:`~Boxes.data` stay the flattened
      storage ``(B * T, N, 4, 2)``.
    - Indexing selects the video batch axis while preserving the temporal axis. An integer index returns a
      one-video :class:`VideoBoxes` so :meth:`to_tensor` keeps the shape ``(1, T, ...)``. Index
      assignment, ``video_boxes[key] = other``, writes the same whole videos.
    - A transformation matrix is ``(B * T, 3, 3)``; a ``(3, 3)`` matrix raises ``ValueError``
      unless :math:`B \cdot T = 1`.
    - :meth:`Boxes.transform_boxes`, :meth:`Boxes.translate`, :meth:`Boxes.clamp`,
      :meth:`Boxes.filter_boxes_by_area` and :meth:`Boxes.merge` return a new :class:`VideoBoxes`;
      :meth:`Boxes.pad`, :meth:`Boxes.unpad`, :meth:`Boxes.to` and :meth:`Boxes.type` update and return ``self``.
    - Every frame holds the same number of rows, with no trimmed export. The padding of list-built :class:`Boxes`
      merged or written into a :class:`VideoBoxes` is marked invalid, so it exports as exact zeros in every mode
      and draws no mask.

Attributes:
    temporal_channel_size: Number of frames :math:`T` stored with the boxes.

See Also:
    - :class:`Boxes`: the 2D boxes of single images, imported from any mode, with no temporal axis.
    - :class:`Boxes3D`: boxes in a ``(D, H, W)`` volume, eight corners each, rather than boxes per frame.
    - :class:`~kornia.augmentation.container.VideoSequential`: the video augmentation whose boxes
      :class:`~kornia.augmentation.container.AugmentationSequential` keeps in this class.

rK   Útemporal_channel_sizec               ó    € V ^8„  d   QhRRRR/# rá   r   )r   s   "r   r   ÚVideoBoxes.__annotate__ó  s   € ÷ ñ Ð$:ð ¸tñ r   c                óJ   € Wn         V P                  4       V n        RV n         R# )z`Mark the padding rows invalid: a video exports every row of every frame, with no trimmed export.N)rÌ   rõ   rË   rå   s   &&r   rÍ   ÚVideoBoxes._set_paddingó  s   € àŒØ×1Ñ1Ó3ˆŒØˆŽr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r)   r¶   r˜   r   r   r   r   )r   s   "r   r   rú  ú  s$   € ÷ "ñ "Ð Að "ÐSWð "Ðcmñ "r   c           
     óî  € \        V\        34      '       g@   VP                  4       ^8w  g+   VP                  RR \        P
                  ! ^^.4      8w  d   \        R4      hVP                  ^4      p\        VP                  VP                  ^ 4      VP                  ^4      ,          VP                  ^4      VP                  ^4      VP                  ^4      4      RVR7      pV ! VRR4      pW5n
        V# )aE  Create :class:`VideoBoxes` from a video box tensor.

Args:
    boxes: Box corners with shape ``(B, T, N, 4, 2)`` in
        ``vertices_plus`` order (top-left, top-right, bottom-right,
        bottom-left), stored unchanged; integer input is cast to
        ``float32``, or ``float64`` when that is the default dtype. Floating-point input keeps its dtype.
        Lists of tensors are not supported yet.
    validate_boxes: Reject a non-finite coordinate with ``RuntimeError``
        (``torch._assert_async``). There is no extent or shape
        check, as for ``'vertices_plus'`` in
        :meth:`~kornia.geometry.boxes.Boxes.from_tensor`.

Returns:
    :class:`VideoBoxes` with ``temporal_channel_size`` set to
    ``boxes.size(1)``.

Raises:
    ValueError: If ``boxes`` is a list or does not have shape
        ``(B, T, N, 4, 2)``.
NzQInput box type is not yet supported. Please input an `BxTxNx4x2` tensor directly.r�   r‚  Fr.   )ra   rd   r0   r/   r    r   ro   r3  rª   rl   rø  )rƒ  r)   r˜   rø  r©   Úouts   &&&   r   r…  ÚVideoBoxes.from_tensorù  sÏ   € ô. �eœd˜W×%Ò%¨%¯)©)«+¸Ô*:¸e¿k¹kÈ"È#Ð>NÔRW×R\ÒR\Ð^_ÐabÐ]cÓRdÔ>dÜÐpÓqÐqà %§
¡
¨1£Ðä1Ø�M‰M˜%Ÿ*™* Q›-¨%¯*©*°Q«-Õ7¸¿¹ÀA»ÈÏ
É
ÐSTËÐW\×WaÑWaÐbcÓWdÓeØ Ø)ô
ˆñ
 �. %¨Ó9ˆØ$9Ô!Øˆ
r   c               ó    € V ^8„  d   QhRRRR/# )r   r[   rü   r   r   r   )r   s   "r   r   rú    s   € ÷ ñ Ð9ð ¸jñ r   c                ó  € V P                   P                  ^ ,          V P                  ,          pV P                   P                  ! W P                  .V P                   P                  R,          O5!  pW1,          pVP                  V P                   P                  8X  d   VP                  ^ 4      pVP                  ^ ^4      p\        V 4      ! VR4      pV P                  Vn        V P                  P                  W P                  V P                  P                  R,          4      V,          pVP                  VP                   P                  RR 4      Vn	        VP                   VJd   VP                  4        V P                  Vn        V# )zñSelect videos while preserving the temporal axis.

An integer or scalar tensor keeps a singleton video-batch dimension. Slices, integer tensors, and boolean
tensors follow the corresponding PyTorch indexing behavior on the video-batch axis.
rL  FNrk   r.   )rÈ   r/   rø  rv  rm   rn   ro  re   rÉ   rË   rl   rë   )rÎ   r[   Ú
batch_sizeÚ
video_datarþ   Úframesrÿ  Úselected_valids   &&      r   r  ÚVideoBoxes.__getitem__  s)  € ð —Z‘Z×%Ñ% aÕ(¨D×,FÑ,FÕFˆ
Ø—Z‘Z—_’_ Z×1KÑ1KÐcÈdÏjÉj×N^ÑN^Ð_aÕNbÓcˆ
Ø•?ˆØ�=‰=˜DŸJ™JŸO™OÔ+Ø×)Ñ)¨!Ó,ˆHà×!Ñ! ! QÓ'ˆÜ�4Œj˜ Ó'ˆØ—J‘JˆŒ	ØŸ™×)Ñ)¨*×6PÑ6PÐRV×R]ÑR]×RcÑRcÐdfÕRgÓhÐilÕmˆØ#×+Ñ+¨C¯I©I¯O©O¸C¸RÐ,@ÓAˆŒ
Ø�9‰9˜FÓ"Ø×ÑÔØ$(×$>Ñ$>ˆÔ!Øˆ
r   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r[   rü   rÝ   r   r   r   r   )r   s   "r   r   rú  4  s"   € ÷ ñ Ð9ð À%ð ÈJñ r   c                óî  € V P                   p\        V\        4      '       d.   VP                   V8w  d   \        RVP                    RV R24      hV P                  P
                  ^ ,          V,          VP                  P
                  ^ ,          V,          rTVP                  P                  ! WS.VP                  P
                  R,          O5!  V P                  P                  ! WC.V P                  P
                  R,          O5!  V&   VP                  4       pVP                  WSVP
                  R,          4      V P                  P                  WCV P                  P
                  R,          4      V&   V # )a,  Write whole videos, selected by ``key`` on the video-batch axis as in :meth:`__getitem__`.

A :class:`VideoBoxes` value must have the same ``temporal_channel_size``: otherwise its frames would be
regrouped into videos of another length. A plain :class:`Boxes` value is read as frames of this length.
zCannot assign videos of z frames to videos of z frames.rL  rk   )
rø  ra   r   ro   rÈ   r/   rî   rv  rõ   rË   )rÎ   r[   rÝ   r3  rW   ÚmÚvalue_valids   &&&    r   r  ÚVideoBoxes.__setitem__4  s,  € ð ×)Ñ)ˆÜ�eœZ×(Ò(¨U×-HÑ-HÈDÔ-PÜØ*¨5×+FÑ+FÐ*GÐG\Ð]aÐ\bÐbjÐkóð ð �z‰z×Ñ Õ" dÕ*¨E¯J©J×,<Ñ,<¸QÕ,?À4Õ,Gˆ1Ø?D¿z¹z¿ºÈqÐ?nÐY^×YcÑYc×YiÑYiÐjlÕYmÓ?nˆ�
‰
�Š˜Ð7 $§*¡*×"2Ñ"2°2Õ"6Ó7¸Ñ<Ø×2Ñ2Ó4ˆØ@K×@PÑ@PÐQRÐZe×ZkÑZkÐlnÕZoÓ@pˆ�‰×Ñ˜ $§+¡+×"3Ñ"3°BÕ"7Ó8¸Ñ=Øˆr   c               ó$   € V ^8„  d   QhRRRRRR/# rˆ  r   )r   s   "r   r   rú  F  s)   € ÷ Sñ SØ!ðSØ>BðSà	*ñSr   c                ó  <€ \        \        P                  \        SV `  WR7      4      pV P
                  P                  ^ ,          V P                  ,          pVP                  ! W@P                  .VP                  R,          O5!  # )a‘  Cast :class:`VideoBoxes` to a tensor with the temporal axis restored.

Args:
    mode: Output box format forwarded to :meth:`Boxes.to_tensor`. When
        ``None``, uses the stored mode (``vertices_plus`` by default).
    as_padded_sequence: Forwarded to :meth:`Boxes.to_tensor`. It only
        changes the result of a list-backed container; a
        :class:`VideoBoxes` is never list-backed, so the value makes no
        difference there. The keyword is accepted because the inherited
        :meth:`Boxes.get_boxes_shape` and :meth:`Boxes.to_mask` pass it.

Returns:
    Tensor shaped ``(B, T, ...)`` where :math:`T` is
    ``temporal_channel_size``.
r  rL  )	r   r    rb   Úsuperr  rÈ   r/   rø  rl   )rÎ   r—   r  rÿ  r  Ú	__class__s   &&&  €r   r  ÚVideoBoxes.to_tensorF  sc   ø€ ô$ ”5—<‘<¤¡Ñ!2°4Ð!2Ó!_Ó`ˆØ—Z‘Z×%Ñ% aÕ(¨D×,FÑ,FÕFˆ
Ø�{Š{˜:×'AÑ'AÐRÀCÇIÁIÈbÅMÓRÐRr   c               ó   € V ^8„  d   QhRR/# )r   r   r   r   )r   s   "r   r   rú  \  s   € ÷ ñ �zñ r   c                óþ   € \        V 4      ! V P                  P                  4       R4      pV P                  Vn        V P                  P                  4       Vn        V P
                  Vn        V P                  Vn        V# )z¾Create an independent copy of the video box container.

Returns:
    New :class:`VideoBoxes` with cloned tensor storage and the same
    ``temporal_channel_size``, mode, and batch metadata.
F)re   rÈ   r¦   rÉ   rË   rÇ   rø  rè  s   & r   r¦   ÚVideoBoxes.clone\  s`   € ô �4Œj˜Ÿ™×)Ñ)Ó+¨UÓ3ˆØ—J‘JˆŒ	Ø—[‘[×&Ñ&Ó(ˆŒ
Ø×*Ñ*ˆŒØ$(×$>Ñ$>ˆÔ!Øˆ
r   c               ó   € V ^8„  d   QhRR/# ró   r   )r   s   "r   r   rú  j  s   € ÷ 
Uñ 
U˜lñ 
Ur   c                óÚ   <€ \         SV `  4       pV P                  P                  ^ ,          V P                  ,          pVP
                  ! W P                  .VP                  R,          O5!  # )zÐCompute polygon area with the shoelace formula with the temporal axis restored.

See the Convention block on :class:`~kornia.geometry.boxes.VideoBoxes`.

Returns:
    Area for each box, shaped ``(B, T, N)``.
rL  )r  rb  rÈ   r/   rø  rl   )rÎ   re  r  r  s   &  €r   rb  ÚVideoBoxes.compute_areaj  sT   ø€ ô ‰wÑ#Ó%ˆØ—Z‘Z×%Ñ% aÕ(¨D×,FÑ,FÕFˆ
Ø�|Š|˜J×(BÑ(BÐTÀTÇZÁZÐPRÅ^ÓTÐTr   c               ó$   € V ^8„  d   QhRRRRRR/# r–  r   )r   s   "r   r   rú  v  s&   € ÷ Uñ U˜cð U¨#ð U°,ñ Ur   c                óÜ   <€ \         SV `  W4      pV P                  P                  ^ ,          V P                  ,          pVP
                  ! W@P                  .VP                  R,          O5!  # )a]  Convert 2D video boxes to masks with the temporal axis restored.

See the Convention block on :class:`~kornia.geometry.boxes.VideoBoxes`.

Args:
    height: height of the masked image/images.
    width: width of the masked image/images.

Returns:
    The output mask tensor, shaped ``(B, T, N, height, width)`` and dtype of
    :func:`Boxes.dtype`.
rL  )r  r±  rÈ   r/   rø  rl   )rÎ   r{   rz   r¤  r  r  s   &&&  €r   r±  ÚVideoBoxes.to_maskv  sU   ø€ ô ‰w‰˜vÓ-ˆØ—Z‘Z×%Ñ% aÕ(¨D×,FÑ,FÕFˆ
Ø�|Š|˜J×(BÑ(BÐTÀTÇZÁZÐPRÅ^ÓTÐTr   )rÌ   rË   )Tr  )rM  rð  rñ  rò  ró  Ú__annotations__rÍ   rõ  r…  r  r  r  r¦   rb  r±  rö  Ú__classcell__)r  s   @r   r   r   Á  s^   ø‡ ñ-ð^ Óõð ö"ó ð"õHõ,÷$Sò Sõ,÷
Uð 
U÷Uö Ur   c                  ó  € ] tR tRtRtR#R R lltR R ltR R lt]R	 R
 l4       t	R R lt
]R$R R ll4       tR%R R lltR R ltR&R R lltR R lt]R R l4       t]R R l4       t]R R l4       t]R R l4       tR'R  R! lltR"tR# )(r   iˆ  aH  Store 3D boxes as eight inclusive corners, converting to and from xyzxyz and xyzwhd.

``boxes = Boxes3D.from_tensor(xyzxyz)`` takes ``(N, 6)`` or ``(B, N, 6)`` boxes in ``'xyzxyz'`` (the default),
``'xyzxyz_plus'`` or ``'xyzwhd'`` mode and stores them as ``(N, 8, 3)`` or ``(B, N, 8, 3)`` inclusive corners;
``boxes.to_tensor('xyzwhd')`` exports them in any of these modes or as corners. In between,
:meth:`transform_boxes` applies ``4 x 4`` matrices to all eight corners and :meth:`to_mask` draws
``(N, D, H, W)`` or ``(B, N, D, H, W)`` masks. Unlike :class:`Boxes` it takes no list input and has no padding,
clamping, merging or area filtering. For one box per volume as a plain ``(B, 8, 3)`` tensor, use
:func:`~kornia.geometry.bbox.bbox_to_mask3d` and :func:`~kornia.geometry.bbox.infer_bbox_shape3d`.

Args:
    boxes: 3D boxes, shape of ``(N,8,3)`` or ``(B,N,8,3)``. See below for more details.
    raise_if_not_floating_point: flag to control floating point casting behaviour when `boxes` is not a floating
        point tensor. True to raise an error when `boxes` isn't a floating point tensor, False to cast to
        ``float32``, or ``float64`` when that is the default dtype. Floating-point input keeps its dtype.
    mode: Representation label reported by :attr:`mode`. The constructor does not convert ``boxes`` and
        :meth:`to_tensor` does not consult the label; use :meth:`from_tensor` to import another representation.

Convention:
    - A box is a `hexahedron <https://en.wikipedia.org/wiki/Hexahedron>`_ of eight floating-point
      ``(x, y, z)`` vertices, ``(N, 8, 3)`` or ``(B, N, 8, 3)``: front-top-left, front-top-right,
      front-bottom-right, front-bottom-left, then the same four back vertices.
    - The stored form is **inclusive** (``depth = zmax - zmin + 1``), as for :class:`Boxes`. :meth:`from_tensor`
      takes ``(N, 6)`` or ``(B, N, 6)`` in ``'xyzxyz'``, ``'xyzwhd'`` (exclusive) or
      ``'xyzxyz_plus'``; the vertex modes exist for :meth:`to_tensor` only. Modes are case-insensitive.
    - :meth:`to_tensor` exports the ``amin``/``amax`` axis-aligned bounding box and defaults to ``'xyzxyz'``
      whatever the stored label.
    - :meth:`get_boxes_shape` returns ``(depths, heights, widths)``, inclusive.
    - :func:`~kornia.geometry.bbox.infer_bbox_shape3d` and :func:`~kornia.geometry.bbox.bbox_to_mask3d` read
      their input as inclusive: pass them the ``'vertices_plus'`` export, unbatched.
    - With ``validate_boxes=True``, :meth:`from_tensor` rejects a non-finite coordinate and extents that are
      not positive in the given mode (``xmax == xmin`` fails in ``'xyzxyz'``, passes in ``'xyzxyz_plus'``).
    - The constructor rejects an integer tensor unless ``raise_if_not_floating_point=False``;
      :meth:`from_tensor` casts integer input to ``float32``,
      or ``float64`` when that is the default dtype.
    - :meth:`transform_boxes` returns a new object labelled ``'xyzxyz_plus'``; :meth:`transform_boxes_`
      rebinds the internal tensor of ``self`` and keeps the label.
    - Integer indexing selects one image's box set for batched input, or one box with shape ``(1, 8, 3)`` for
      unbatched input. Scalar integer tensors follow the same rule.

.. warning::
    The inclusive ``+1`` is `#3934 <https://github.com/kornia/kornia/issues/3934>`_ and the ``'vertices'``
    export trap `#4009 <https://github.com/kornia/kornia/issues/4009>`_. The integer-input split is
    `#4012 <https://github.com/kornia/kornia/issues/4012>`_ and the validator split with
    :func:`~kornia.geometry.bbox.validate_bbox` is `#4013 <https://github.com/kornia/kornia/issues/4013>`_.
    The :meth:`to_tensor` default differs from :meth:`Boxes.to_tensor`, which defaults to the stored mode:
    `#4251 <https://github.com/kornia/kornia/issues/4251>`_.

See Also:
    - :class:`Boxes`: 2D boxes as four corners, with list input, padding, clamping and area filtering.
    - :class:`VideoBoxes`: the 2D boxes of ``(B, T)`` video frames, rather than boxes in a volume.
    - :func:`~kornia.geometry.bbox.bbox_to_mask3d`: the ``(B, 1, D, H, W)`` mask of one box per volume of a plain
      ``(B, 8, 3)`` tensor, with truncated bounds.
    - :func:`~kornia.geometry.bbox.infer_bbox_shape3d`: the inclusive sizes of a plain ``(B, 8, 3)`` tensor.
    - :class:`~kornia.geometry.keypoints.Keypoints3D`: ``(x, y, z)`` points, transformed by the same ``4 x 4``
      matrices.

c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r   r)   rL   r·   r   r—   r+   r   r‰   r   )r   s   "r   r   ÚBoxes3D.__annotate__Ä  s,   € ÷ ñ Ø!ðØ@DðØSVðà	ñr   c                	ó"  € \        V\        P                  4      '       g   \        R \	        V4       R24      hVP                  4       '       g-   V'       d   \        RVP                   R24      h\        V4      p\        VP                  4      ^ 8X  d   VP                  R4      p^VP                  u;8:  d   ^8:  d   M MVP                  RR R8X  g   \        RVP                   R24      hVP                  ^8g  V n        Wn        W0n        R# )rÀ   r6   r¾   Nz53D bbox shape must be (N, 8, 3) or (B, N, 8, 3). Got )rk   é   r.   )é   r„   )ra   r    rb   r=   re   r¼   ro   r   r   rÆ   r/   rl   rm   rÇ   rÈ   rÉ   )rÎ   r)   r·   r—   s   &&&&r   rÒ   ÚBoxes3D.__init__Ä  sÞ   € ô ˜%¤§¡×.Ò.ÜÐ@ÄÀeÃÀÈQÐOÓPÐPà×&Ñ&×(Ò(ß*Ü Ð#NÈuÏ{É{ÈmÐ[\Ð!]Ó^Ð^ä+¨EÓ2ˆEäˆu�{‰{Ó˜qÔ Ø—M‘M 'Ó*ˆEà�U—Z‘ZÖ$ 1×$¨¯©°R°SÐ)9¸VÔ)CÜÐTÐUZ×U`ÑU`ÐTaÐabÐcÓdÐdà Ÿ:™:¨™?ˆÔàŒ
ØŽ
r   c               ó    € V ^8„  d   QhRRRR/# )r   r[   rü   r   r   r   )r   s   "r   r   r  Û  s   € ÷ ñ Ð9ð ¸gñ r   c                	óÚ   € V P                   V,          pVP                  ^8X  d(   \        V\        4      '       g   VP	                  ^ 4      p\        VRRR7      pV P                  Vn        V# )r   FÚxyzxyz_plus©r—   )rÈ   rm   ra   rc   rn   r   rÉ   )rÎ   r[   rî   r   s   &&  r   r  ÚBoxes3D.__getitem__Û  sR   € Ø�z‰z˜#�ˆØ�9‰9˜Œ>¤*¨S´%×"8Ò"8à—>‘> !Ó$ˆDÜ˜$ ¨MÔ:ˆØŸ
™
ˆŒØˆr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r[   rü   rÝ   r   r   r   )r   s   "r   r   r  ä  s"   € ÷ ñ Ð9ð À'ð Ègñ r   c                	ó8   € VP                   V P                   V&   V # r   rÆ  r  s   &&&r   r  ÚBoxes3D.__setitem__ä  s   € ØŸ+™+ˆ�
‰
�3‰Øˆr   c               ó   € V ^8„  d   QhRR/# r  r   )r   s   "r   r   r  é  s   € ÷ 	ñ 	Ð-ñ 	r   c                ó.   € V P                   P                  # )a<  Return the tensor shape used to store 3D boxes.

Returns:
    Shape of :attr:`data`. For unbatched boxes this is usually
    ``(N, 8, 3)``, where :math:`N` is the number of boxes, ``8`` is
    the number of cuboid corners, and ``3`` stores ``(x, y, z)``. For
    batched boxes the shape is usually ``(B, N, 8, 3)``.
r  rê   s   &r   r/   ÚBoxes3D.shapeè  s   € ð �y‰y�‰Ðr   c               ó   € V ^8„  d   QhRR/# )r   r   z/tuple[torch.Tensor, torch.Tensor, torch.Tensor]r   )r   s   "r   r   r  ô  s   € ÷ 'ñ 'Ð!Pñ 'r   c                ób   € V P                  RR7      pVR,          VR,          VR,          rCpWCV3# )a  Compute boxes depths, heights and widths.

See the Convention block on :class:`~kornia.geometry.boxes.Boxes3D`.

Returns:
    - Boxes depths, shape of ``(N,)`` or ``(B,N)``.
    - Boxes heights, shape of ``(N,)`` or ``(B,N)``.
    - Boxes widths, shape of ``(N,)`` or ``(B,N)``.

Example:
    >>> boxes_xyzxyz = torch.tensor([[ 0,  1,  2, 10, 21, 32], [3, 4, 5, 43, 54, 65]])
    >>> boxes3d = Boxes3D.from_tensor(boxes_xyzxyz)
    >>> boxes3d.get_boxes_shape()
    (tensor([30., 60.]), tensor([20., 50.]), tensor([10., 40.]))

Úxyzwhdr'  r¡   ©.rÁ   ©.é   )r  )rÎ   Úboxes_xyzwhdr  r  Údepthss   &    r   r  ÚBoxes3D.get_boxes_shapeô  s:   € ð" —~‘~¨8�~Ó4ˆØ".¨vÕ"6¸ÀVÕ8LÈlÐ[aÕNb˜ˆØ Ð&Ð&r   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r   r)   rL   r—   r+   r˜   r   r   r   r   )r   s   "r   r   r  
  s6   € ÷ TNñ TN ð TN°Cð TNÐTXð TNÐdkñ TNr   c                óð  € ^VP                   u;8:  d   ^8:  d   M MVP                  R,          ^8X  g   \        RVP                   R24      hVP                   ^8H  pV'       d   TMVP                  ^ 4      p\	        V4      pVR,          VR,          VR,          rvpVP                  4       pVR8X  dG   VR,          VR,          ,
          pVR,          VR,          ,
          p	VR,          VR,          ,
          p
M’VR8X  d\   VR,          VR,          ,
          ^,           pVR,          VR,          ,
          ^,           p	VR,          VR,          ,
          ^,           p
M0VR8X  d   VR,          VR,          VR,          r©pM\        RV 24      hV'       d²   \        4       '       g¢   \        P                  ! V4      P                  4       '       g   \        R4      hV^ 8*  P                  4       '       d   \        R4      hV	^ 8*  P                  4       '       d   \        R	4      hV
^ 8*  P                  4       '       d   \        R
4      h\        WVWxWš4      pV'       d   TMVP                  ^ 4      pV ! VRVR7      # )aM  Create :class:`Boxes3D` from 3D boxes stored in another format.

See the Convention block on :class:`~kornia.geometry.boxes.Boxes3D`.

Args:
    boxes: 3D boxes, shape of ``(N,6)`` or ``(B,N,6)``. Integer input is cast to
        ``float32``, or ``float64`` when that is the default dtype. Floating-point input keeps its dtype.
    mode: The format in which the 3D boxes are provided, matched case-insensitively.

        * 'xyzxyz': boxes are assumed to be in the format ``xmin, ymin, zmin, xmax, ymax, zmax`` where
          ``width = xmax - xmin``, ``height = ymax - ymin`` and ``depth = zmax - zmin``.
        * 'xyzxyz_plus': similar to 'xyzxyz' mode but where box width, length and depth are defined as
          ``width = xmax - xmin + 1``, ``height = ymax - ymin + 1`` and ``depth = zmax - zmin + 1``.
        * 'xyzwhd': boxes are assumed to be in the format ``xmin, ymin, zmin, width, height, depth`` where
          ``width = xmax - xmin``, ``height = ymax - ymin`` and ``depth = zmax - zmin``.

    validate_boxes: reject boxes with a non-finite coordinate, and boxes whose width, height or depth
        is not positive when measured in the given mode's convention, so ``xmax == xmin`` is rejected in
        ``'xyzxyz'`` and accepted in ``'xyzxyz_plus'``. The checks read the data, so graph capture
        (``torch.compile``, ``torch.export``) skips them.

Returns:
    :class:`Boxes3D` containing the converted inclusive vertex representation, labelled with ``mode``.

Examples:
    >>> boxes_xyzxyz = torch.as_tensor([[0, 3, 6, 1, 4, 8], [5, 1, 3, 8, 4, 9]])
    >>> boxes = Boxes3D.from_tensor(boxes_xyzxyz, mode='xyzxyz')
    >>> boxes.data  # (2, 8, 3)
    tensor([[[0., 3., 6.],
             [0., 3., 6.],
             [0., 3., 6.],
             [0., 3., 6.],
             [0., 3., 7.],
             [0., 3., 7.],
             [0., 3., 7.],
             [0., 3., 7.]],
    <BLANKLINE>
            [[5., 1., 3.],
             [7., 1., 3.],
             [7., 3., 3.],
             [5., 3., 3.],
             [5., 1., 8.],
             [7., 1., 8.],
             [7., 3., 8.],
             [5., 3., 8.]]])

z,BBox shape must be (N, 6) or (B, N, 6). Got r6   Úxyzxyzr&  r1  rœ   r‹   rŒ   r�   z%Some boxes have negative depths or 0.F)r·   r—   rk   r}   r~   r¢   r¡   r2  r3  )rm   r/   ro   rn   r   r£   r   r    r�   r<   r�   r³   r§   )rƒ  r)   r—   r˜   r¨   rx   ry   r¬   rz   r{   r­   Úhexahedronss   &&&&        r   r…  ÚBoxes3D.from_tensor	  s  € ðb �U—Z‘ZÖ$ 1×$¨¯©°R­¸AÔ)=ÜÐKÈEÏKÉKÈ=ÐXYÐZÓ[Ð[à—*‘* ‘/ˆß ‘ e§o¡o°aÓ&8ˆÜ'¨Ó.ˆà  �=¨%°­-¸¸v½�DˆØ�z‰z‹|ˆØ�8ÔØ˜&•M E¨&¥MÕ1ˆEØ˜6•] U¨6¥]Õ2ˆFØ˜&•M E¨&¥MÕ1‰EØ�]Ô"Ø˜&•M E¨&¥MÕ1°AÕ5ˆEØ˜6•] U¨6¥]Õ2°QÕ6ˆFØ˜&•M E¨&¥MÕ1°AÕ5‰EØ�XÔØ#(¨¥=°%¸µ-ÀÀvÅ˜5ˆE˜5ä˜}¨T¨FÐ3Ó4Ð4÷ ¤,§.¢.Ü—>’> %Ó(×,Ñ,×.Ò.Ü Ð!JÓKÐKØ˜‘
×Ñ×!Ò!Ü Ð!HÓIÐIØ˜!‘× Ñ ×"Ò"Ü Ð!IÓJÐJØ˜‘
×Ñ×!Ò!Ü Ð!HÓIÐIä,¨T¸ÀfÓTˆß%,‘k°+×2EÑ2EÀaÓ2HˆÙ�;¸EÈÔMÐMr   c               ó    € V ^8„  d   QhRRRR/# )r   r—   r+   r   rL   r   )r   s   "r   r   r  `  s   € ÷ L?ñ L?˜cð L?°ñ L?r   c                óì  € V P                   '       d   V P                  MV P                  P                  ^ 4      p\        P                  ! VP                  RR7      VP                  RR7      .RR7      P                  VP                  ^ ,          VP                  ^,          ^4      pVP                  4       pVR9   d   M|VR9   dh   VR,          VR	,          ,
          ^,           pVR
,          VR,          ,
          ^,           pVR,          VR,          ,
          ^,           pWCR&   WSR
&   WcR&   M\        RV 24      hVR9   d8   \        P                  ! . ROVP                  VP                  R7      pW7,           pVP                  R4      '       dB   VR	,          VR,          VR,          r©pVR,          VR
,          VR,          rep\        W‰W¤WV4      pV P                   '       d   V# VP!                  ^ 4      # )aÒ	  Cast :class:`Boxes3D` to a tensor.

See the Convention block on :class:`~kornia.geometry.boxes.Boxes3D`.

Convention:
    ``mode`` defaults to ``'xyzxyz'`` regardless of the stored label
    (`#4251 <https://github.com/kornia/kornia/issues/4251>`_). Every export is the ``amin``/``amax``
    axis-aligned bounding box of the stored vertices.

Args:
    mode: The format in which the boxes are provided, matched case-insensitively.

        * 'xyzxyz': boxes are assumed to be in the format ``xmin, ymin, zmin, xmax, ymax, zmax`` where
          ``width = xmax - xmin``, ``height = ymax - ymin`` and ``depth = zmax - zmin``.
        * 'xyzxyz_plus': similar to 'xyzxyz' mode but where box width, length and depth are defined as
          ``width = xmax - xmin + 1``, ``height = ymax - ymin + 1`` and ``depth = zmax - zmin + 1``.
        * 'xyzwhd': boxes are assumed to be in the format ``xmin, ymin, zmin, width, height, depth`` where
          ``width = xmax - xmin``, ``height = ymax - ymin`` and ``depth = zmax - zmin``.
        * 'vertices': boxes are defined by their vertices points in the following ``clockwise`` order:
          *front-top-left, front-top-right, front-bottom-right, front-bottom-left, back-top-left,
          back-top-right, back-bottom-right,  back-bottom-left*. Vertices coordinates are in (x,y, z) order.
          Finally, box width, height and depth are defined as ``width = xmax - xmin``, ``height = ymax - ymin``
          and ``depth = zmax - zmin``.
        * 'vertices_plus': similar to 'vertices' mode but where box width, height and depth are defined as
          ``width = xmax - xmin + 1``, ``height = ymax - ymin + 1`` and ``depth = zmax - zmin + 1``; this is
          the stored form.

Returns:
    3D Boxes tensor in the ``mode`` format. The shape depends with the ``mode`` value:

        * 'vertices' or 'vertices_plus': ``(N, 8, 3)`` or ``(B, N, 8, 3)``.
        * Any other value: ``(N, 6)`` or ``(B, N, 6)``.

Note:
    The ``amin``/``amax`` reduction ties on every face of an axis-aligned box (4 vertices share each
    extremum), so the gradient there is a subgradient shared among the tied vertices; it sums to one
    over them but need not match a finite-difference estimate such as
    :func:`~torch.autograd.gradcheck.gradcheck`.

Examples:
    >>> boxes_xyzxyz = torch.as_tensor([[0, 3, 6, 1, 4, 8], [5, 1, 3, 8, 4, 9]])
    >>> boxes = Boxes3D.from_tensor(boxes_xyzxyz, mode='xyzxyz')
    >>> assert (boxes.to_tensor(mode='xyzxyz') == boxes_xyzxyz).all()

r¯   rš   rœ   rO   r.   )r:  r&  )r1  rš   r�   r¡   r}   r2  r~   r3  r¢   )r:  rš   )r9   r9   r9   r   r   r   )rÇ   rÈ   rn   r    rŽ   r‹  rŒ  rv  r/   r£   ro   rT   rP   r   r¤   r³   r§   )rÎ   r—   r�  r)   rz   r{   r­   rA  rx   ry   r¬   s   &&         r   r  ÚBoxes3D.to_tensor`  s®  € ð\ '+×&6×&6Ð&6˜Ÿ
š
¸D¿J¹J×<PÑ<PÐQRÓ<Sˆô —’˜]×/Ñ/°BÐ/Ó7¸×9KÑ9KÐPRÐ9KÓ9SÐTÐZ\Ô]×bÑbØ×Ñ Õ" M×$7Ñ$7¸Õ$:¸Aó
ˆð �z‰z‹|ˆØÐ,Ô,ØØÐ<Ô<Ø˜&•M E¨&¥MÕ1°AÕ5ˆEØ˜6•] U¨6¥]Õ2°QÕ6ˆFØ˜&•M E¨&¥MÕ1°AÕ5ˆEØ!�&‰MØ"�&‰MØ!�&ŠMä˜}¨T¨FÐ3Ó4Ð4àÐ)Ô)Ü—_’_Ò%7ÀÇÁÐTY×T_ÑT_Ô`ˆFØ•NˆEà�?‰?˜:×&Ò&Ø$ V�}¨e°F­m¸UÀ6½]˜ˆDØ#(¨¥=°%¸µ-ÀÀvÅ˜5ˆEä*¨4°tÀFÓRˆEà×(×(Ð(ˆuÐ>¨e¯m©m¸AÓ.>Ð>r   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   r­   rK   r{   rz   r   rL   r   )r   s   "r   r   r  ®  s.   € ÷ pñ p˜Sð p¨#ð p°cð p¸lñ pr   c                óÒ  € V P                   P                  '       d   \        R4      hV P                  '       d}   \        P
                  ! V P                   P                  ^ ,          V P                   P                  ^,          WV3V P                   P                  V P                   P                  R7      pM_\        P
                  ! V P                   P                  ^ ,          WV3V P                   P                  V P                   P                  R7      pV P                  R4      pVR,          P                  ^ V4       VR,          P                  ^ V4       VR,          P                  ^ V4       VP                  R^4      P                  4       P                  4       p\        4       '       g&   \        P                  P!                  4       '       Ed6   V P                   P                  p\        P"                  ! WR7      p\        P"                  ! W'R7      p	\        P"                  ! W7R7      p
VR	,          VR
,          8¬  VR	,          VR,          8  ,          pV	R	,          VR,          8¬  V	R	,          VR,          8  ,          pV
R	,          VR,          8¬  V
R	,          VR,          8  ,          pVR,          VR,          ,          VR,          ,          pVP%                  VP                  4      P                  VP                  4      # \'        VP)                  ^ R4      V4       F>  w  pp^VV^,          V^,          1V^,          V^,          1V^ ,          V^,          13&   K@  	  V# )aÈ  Convert 3D boxes to masks. Covered area is 1 and the remaining is 0.

See the Convention block on :class:`~kornia.geometry.boxes.Boxes3D`.

Convention:
    The size is ``(depth, height, width)`` and the mask ``(N, depth, height, width)`` or
    ``(B, N, depth, height, width)`` in the box dtype, with no channel axis. The exclusive
    ``'xyzxyz'`` export is clamped to the volume, rounded to the nearest integer and filled over
    half-open ranges. A box tensor that requires grad raises ``RuntimeError``.

.. warning::
    :func:`~kornia.geometry.bbox.bbox_to_mask3d` truncates instead of rounding, so a fractional box can
    fill a different volume: `#4015 <https://github.com/kornia/kornia/issues/4015>`_.

Args:
    depth: depth of the masked image/images.
    height: height of the masked image/images.
    width: width of the masked image/images.

Returns:
    the output mask tensor, shape of ``(N, depth, height, width)`` or ``(B, N, depth, height, width)``
    and dtype of :func:`Boxes3D.dtype` (it can be any floating point dtype).

Note:
    It is currently non-differentiable.

Examples:
    >>> boxes = Boxes3D(torch.tensor([[  # Same as Boxes3D.from_tensor([[1, 1, 1, 3, 3, 2]], 'xyzxyz_plus')
    ...     [1., 1., 1.],
    ...     [3., 1., 1.],
    ...     [3., 3., 1.],
    ...     [1., 3., 1.],
    ...     [1., 1., 2.],
    ...     [3., 1., 2.],
    ...     [3., 3., 2.],
    ...     [1., 3., 2.],
    ... ]]))  # 1x8x3
    >>> boxes.to_mask(4, 5, 5)
    tensor([[[[0., 0., 0., 0., 0.],
              [0., 0., 0., 0., 0.],
              [0., 0., 0., 0., 0.],
              [0., 0., 0., 0., 0.],
              [0., 0., 0., 0., 0.]],
    <BLANKLINE>
             [[0., 0., 0., 0., 0.],
              [0., 1., 1., 1., 0.],
              [0., 1., 1., 1., 0.],
              [0., 1., 1., 1., 0.],
              [0., 0., 0., 0., 0.]],
    <BLANKLINE>
             [[0., 0., 0., 0., 0.],
              [0., 1., 1., 1., 0.],
              [0., 1., 1., 1., 0.],
              [0., 1., 1., 1., 0.],
              [0., 0., 0., 0., 0.]],
    <BLANKLINE>
             [[0., 0., 0., 0., 0.],
              [0., 0., 0., 0., 0.],
              [0., 0., 0., 0., 0.],
              [0., 0., 0., 0., 0.],
              [0., 0., 0., 0., 0.]]]])

r˜  rš  r:  rQ   ).:NNr„   ).:r   Nr„   ).:r   Nr„   rk   r›  )rS   r>  )rS   :r4  r!  N)rS   :r   r   N)rS   :rÁ   r4  N)rS   :r9   r   N)rS   :r„   rÁ   N)rS   rS   NN)rS   NrS   N)rS   NNrS   éüÿÿÿ)rÈ   rœ  r4  rÇ   r    r…   r/   r   rP   r  r�  rv  r¡  rU   r   rž  rŸ  rV   rÅ   r   ro  )rÎ   r­   r{   rz   r¤  Úclipped_boxes_xyzxyzr:  rP   Úzsr¬  r­  Úz_maskr®  r¯  r°  r¥  Ú
box_xyzxyzs   &&&&             r   r±  ÚBoxes3D.to_mask®  s±  € ð@ �:‰:×#×#Ð#ÜØuóð ð ××ÐÜ—;’;Ø—‘×!Ñ! !Õ$ d§j¡j×&6Ñ&6°qÕ&9¸5È%ÐPØ—j‘j×&Ñ&Ø—z‘z×(Ñ(ô‰Dô —;’;Ø—‘×!Ñ! !Õ$ e°UÐ;À4Ç:Á:×CSÑCSÐ\`×\fÑ\f×\mÑ\môˆDð
  $Ÿ~™~¨hÓ7ÐØ˜XÕ&×-Ñ-¨a°Ô7Ø˜YÕ'×.Ñ.¨q°&Ô9Ø˜YÕ'×.Ñ.¨q°%Ô8ð &×*Ñ*¨2¨qÓ1×7Ñ7Ó9×>Ñ>Ó@ˆä�>Š>œUŸY™Y×1Ñ1×3Ó3ð
 —Z‘Z×&Ñ&ˆFÜ—’˜eÔ3ˆBÜ—’˜fÔ4ˆBÜ—’˜eÔ3ˆBØ˜•k V¨F¥^Ñ3¸¸7½ÀfÈVÅnÑ8TÕUˆFØ˜•k V¨F¥^Ñ3¸¸7½ÀfÈVÅnÑ8TÕUˆFØ˜•k V¨F¥^Ñ3¸¸7½ÀfÈVÅnÑ8TÕUˆFØÐ+Õ,¨vÐ6FÕ/GÕGÈ&ÐQaÕJbÕbˆEØ—8‘8˜DŸJ™JÓ'×,Ñ,¨T¯Z©ZÓ8Ð8ô ),¨D¯L©L¸¸BÓ,?ÀÖ(HÑ$ˆL˜*ð ð Ø˜1• 
¨1¥Ð-¨z¸!­}¸zÈ!½}Ð/LÈjÐYZÍmÐ^hÐijÕ^kÐNkÐkóñ )Ið ˆr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   rg   rL   r  r   r   r   r   )r   s   "r   r   r     s&   € ÷ @ñ @ ð @¸ð @Èñ @r   c                óú   € ^VP                   u;8:  d   ^8:  d   M MVP                  RR R8w  d   \        RVP                   R24      h\        V P                  V4      pV'       d	   W0n        V # \        VRR4      # )aç  Apply a transformation matrix to the 3D boxes.

See the Convention block on :class:`~kornia.geometry.boxes.Boxes3D`.

Args:
    M: The transformation matrix to be applied, shape of ``(4, 4)`` or ``(B, 4, 4)``, where ``B``
        must equal the box batch size and an unbatched box counts as one.
    inplace: do transform in-place and return self.

Returns:
    The transformed boxes: a new :class:`Boxes3D` labelled ``'xyzxyz_plus'`` when ``inplace`` is false,
    otherwise ``self``.

NzAThe transformation matrix shape must be (4, 4) or (B, 4, 4). Got r6   Fr&  r.   )rÁ   rÁ   )rm   r/   ro   rv   rÈ   r   )rÎ   rg   r  ru   s   &&& r   rµ  ÚBoxes3D.transform_boxes   sr   € ð �A—F‘FÖ˜a× 1§7¡7¨2¨3 <°6Ô#9ÜÐ`Ðab×ahÑahÐ`iÐijÐkÓlÐlä,¨T¯Z©Z¸Ó;ÐßØ*ŒJØˆKäÐ(¨%°Ó?Ð?r   c               ó    € V ^8„  d   QhRRRR/# )r   rg   rL   r   r   r   )r   s   "r   r   r  9  s   € ÷ 5ñ 5 ,ð 5°7ñ 5r   c                ó(   € V P                  VRR7      # )aw  Apply :meth:`transform_boxes` in place and return ``self``.

See the Convention block on :class:`~kornia.geometry.boxes.Boxes3D`.

Convention:
    The internal tensor is rebound, not written: a tensor obtained from :attr:`data` before the call
    keeps the old coordinates. The stored mode label is kept.

Returns:
    This :class:`Boxes3D` object after the transformation.
Tr¹  rº  r»  s   &&r   r¼  ÚBoxes3D.transform_boxes_9  r¾  r   c               ó   € V ^8„  d   QhRR/# ró   r   )r   s   "r   r   r  H  s   € ÷ ñ �lñ r   c                ó   € V P                   # )z§Return the raw 3D corner-coordinate tensor.

Returns:
    Tensor containing eight 3D corner coordinates per box, usually
    shaped ``(N, 8, 3)`` or ``(B, N, 8, 3)``.
rÆ  rê   s   &r   rî   ÚBoxes3D.dataG  s   € ð �z‰zÐr   c               ó   € V ^8„  d   QhRR/# rÉ  r   )r   s   "r   r   r  R  rÊ  r   c                ó   € V P                   # )a>  Return the 3D box format remembered by this container.

Returns:
    The mode label given to :meth:`from_tensor` or the constructor; the new object that
    :meth:`transform_boxes` returns is labelled ``'xyzxyz_plus'``. :meth:`to_tensor` does not read it
    (`#4251 <https://github.com/kornia/kornia/issues/4251>`_).
rÌ  rê   s   &r   r—   ÚBoxes3D.modeQ  rÎ  r   c               ó   € V ^8„  d   QhRR/# rÐ  r   )r   s   "r   r   r  ]  rÑ  r   c                ó.   € V P                   P                  # rÓ  rÔ  rê   s   &r   rP   ÚBoxes3D.device\  rÖ  r   c               ó   € V ^8„  d   QhRR/# rØ  r   )r   s   "r   r   r  b  rÙ  r   c                ó.   € V P                   P                  # rÛ  rÜ  rê   s   &r   r   ÚBoxes3D.dtypea  rÞ  r   Nc               ó$   € V ^8„  d   QhRRRRRR/# )r   rP   rà  r   rá  r   r   r   )r   s   "r   r   r  f  s$   € ÷ 
ñ 
Ð/ð 
Ð?Tð 
Ð`gñ 
r   c                óˆ   € Ve   \        V4      '       g   \        R4      hV P                  P                  WR7      V n        V # rã  )r'   ro   rÈ   rÅ   rä  s   &&&r   rÅ   Ú
Boxes3D.tof  s<   € ð ÒÔ%=¸e×%DÒ%DÜÐ>Ó?Ð?Ø—Z‘Z—]‘]¨&�]Ó>ˆŒ
Øˆr   )rÈ   rÇ   rÉ   )Tr&  )r:  T)r:  rí  rï  )rM  rð  rñ  rò  ró  rÒ   r  r  rô  r/   r  rõ  r…  r  r±  rµ  r¼  rî   r—   rP   r   rÅ   rö  r   r   r   r   r   ˆ  s¼   † ñ9÷võ.õð ô	ó ð	õ'ð* öTNó ðTN÷lL?õ\p÷d@õ25ð ôó ðð ôó ðð ô!ó ð!ð ô ó ð ÷
ó 
r   )r   r   r   )r7   rî  )%ró  Ú
__future__r   Útypingr   r   r   r   r    r   Úkornia.core._compatr   Úkornia.core.checkr	   Úkornia.core.opsr
   Úkornia.core.utilsr   r   r   Úkornia.geometry._coordinater   Úkornia.geometry.linalgr   Ú__all__r'   rG   rY   r^   rv   r‡   r•   rª   r³   r   r   r   r   r   r   Ú<module>rf     s‘   ðñ$õ* #ç -Ó -ã Ý å 9Ý *Ý $ß PÑ PÝ ?Ý 3â
,€õ^÷õHõõ,õ:õ$C÷":Dõz>÷<Iñ IôXDU�ô DU÷Nhó hr   