Ë
    èÓ^jS$  ã                  ó*  — d dl mZ d dlZd dlZd dlmZ d dlmZ d dlm	Z	m
Z
mZ d dlZd dlZd dlmZ d dlmZ d dlmZmZmZ d d	lmZmZmZ d d
lmZmZ dd„Zdd„Zdd„Z dd„Z!d„ Z"dd„Z#d d„Z$d!d„Z%d"d„Z&d#d„Z'd$d„Z(d%d„Z)d&d„Z*d'd„Z+d(d„Z,d(d„Z-y))é    )ÚannotationsN)ÚSequence)Úsuppress)ÚAnyÚCallableÚLiteral)Ú
tv_tensors)Úsequence_to_str)Ú_check_sequence_inputÚ_setup_angleÚ_setup_size)Úget_dimensionsÚget_sizeÚis_pure_tensor)Ú	_FillTypeÚ_FillTypeJITc                ót  — t        | t        t        t        f«      st	        |› dt        | «      › �«      ‚t        | t        «      r't        | «      dvrt        d|› dt        | «      › �«      ‚t        | t        «      r6| D ]1  }t        |t        t        f«      rŒt        |› dt        |«      › �«      ‚ t        | t        t        f«      rt        | «      t        | «      g} | S t        | t        «      rHt        | «      dk(  rt        | d   «      t        | d   «      g} | S t        | d   «      t        | d   «      g} | S )Nz2 should be a number or a sequence of numbers. Got )é   é   zIf z0 is a sequence its length should be 1 or 2. Got z& should be a sequence of numbers. Got r   r   )Ú
isinstanceÚintÚfloatr   Ú	TypeErrorÚtypeÚlenÚ
ValueError)ÚargÚnameÚelements      úk/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/torchvision/transforms/v2/_utils.pyÚ_setup_number_or_seqr!      s1  € Ü�cœC¤¬Ð1Ô2Ü˜4˜&Ð RÔSWÐX[ÓS\ÐR]Ð^Ó_Ð_Ü�#”xÔ ¤S¨£X°VÑ%;Ü˜3˜t˜fÐ$TÔUXÐY\ÓU]ÐT^Ð_Ó`Ð`Ü�#”xÔ Øò 	aˆGÜ˜g¬¬U |Õ4Ü  D 6Ð)OÔPTÐU\ÓP]ÈÐ!_Ó`Ð`ð	aô �#œœU�|Ô$Ü�S‹zœ5 ›:Ð&ˆð €Jô 
�CœÔ	"Üˆs‹8�qŠ=Ü˜˜Q™“=¤%¨¨A©£-Ð0ˆCð €Jô ˜˜Q™“=¤%¨¨A©£-Ð0ˆCØ€Jó    c                óÌ   — t        | t        «      r!| j                  «       D ]  }t        |«       Œ y | �1t        | t        j
                  t        t        f«      st        d«      ‚y y )NzNGot inappropriate fill arg, only Numbers, tuples, lists and dicts are allowed.)	r   ÚdictÚvaluesÚ_check_fill_argÚnumbersÚNumberÚtupleÚlistr   )ÚfillÚvalues     r    r&   r&   *   sZ   € Ü�$œÔØ—[‘[“]ò 	#ˆEÜ˜EÕ"ñ	#ð Ð¤J¨t´g·n±nÄeÌTÐ5RÔ$SÜÐlÓmÐmð %TÐr"   c                ó†   — | €| S t        | t        t        f«      s!t        | «      D �cg c]  }t        |«      ‘Œ } }| S c c}w ©N)r   r   r   r*   )r+   Úvs     r    Ú_convert_fill_argr0   3   sA   € ð
 €|Øˆä�dœS¤%˜LÔ)Ü"& t£*Ö-˜Q”�a•Ð-ˆÐ-Ø€Kùò .s   ¨>c                ó¢   — t        | «       t        | t        «      r(| j                  «       D ]  \  }}t	        |«      | |<   Œ | S dt	        | «      iS )NÚothers)r&   r   r$   Úitemsr0   )r+   Úkr/   s      r    Ú_setup_fill_argr5   @   sQ   € Ü�DÔä�$œÔØ—J‘J“Lò 	+‰DˆAˆqÜ'¨Ó*ˆD�ŠGð	+àˆàÔ+¨DÓ1Ð2Ð2r"   c                ó>   — || v r| |   S d| v r| d   S t        d«       y )Nr2   zWThis should never happen, please open an issue on the torchvision repo if you hit this.)ÚRuntimeError)Ú	fill_dictÚ	inpt_types     r    Ú	_get_fillr:   K   s1   € Ø�IÑØ˜Ñ#Ð#Ø	�YÑ	Ø˜Ñ"Ð"äÐnÕor"   c                óÈ   — d| › d�}t        | t        t        f«      r+t        | «      dvst	        d„ | D «       «      st        |«      ‚y t        | t        «      st        |«      ‚y )NzEPadding must be an int or a 1, 2, or 4 element of tuple or list, got ú.)r   r   é   c              3  ó<   K  — | ]  }t        |t        «      –— Œ y ­wr.   )r   r   )Ú.0Úps     r    ú	<genexpr>z%_check_padding_arg.<locals>.<genexpr>X   s   è ø€ Ò3XÈ1´J¸qÄ#×4FÑ3Xùs   ‚)r   r)   r*   r   Úallr   r   )ÚpaddingÚerr_msgs     r    Ú_check_padding_argrE   T   sf   € àUÐV]ÐU^Ð^_Ð`€GÜ�'œE¤4˜=Ô)Üˆw‹<˜yÑ(´Ñ3XÐPWÔ3XÔ0XÜ˜WÓ%Ð%ð 1Yä˜¤Ô%Ü˜Ó!Ð!ð &r"   c                ó"   — | dvrt        d«      ‚y )N)ÚconstantÚedgeÚreflectÚ	symmetriczBPadding mode should be either constant, edge, reflect or symmetric)r   )Úpadding_modes    r    Ú_check_padding_mode_argrL   `   s   € ØÐGÑGÜÐ]Ó^Ð^ð Hr"   c                óô  — t        | t        t        f«      r| d   } t        | «      r| S t        | t        j
                  j                  «      st        d| › d�«      ‚d}t        t        «      5  t        d„ | j                  «       D «       «      }ddd«       |€8t        t        «      5  t        d„ | j                  «       D «       «      }ddd«       |€t        d«      ‚| |   S # 1 sw Y   ŒUxY w# 1 sw Y   Œ'xY w)ap  
    This heuristic covers three cases:

    1. The input is tuple or list whose second item is a labels tensor. This happens for already batched
       classification inputs for MixUp and CutMix (typically after the Dataloder).
    2. The input is a tuple or list whose second item is a dictionary that contains the labels tensor
       under a label-like (see below) key. This happens for the inputs of detection models.
    3. The input is a dictionary that is structured as the one from 2.

    What is "label-like" key? We first search for an case-insensitive match of 'labels' inside the keys of the
    dictionary. This is the name our detection models expect. If we can't find that, we look for a case-insensitive
    match of the term 'label' anywhere inside the key, i.e. 'FooLaBeLBar'. If we can't find that either, the dictionary
    contains no "label-like" key.
    r   z�When using the default labels_getter, the input passed to forward must be a dictionary or a two-tuple whose second item is a dictionary or a tensor, but got z	 instead.Nc              3  óH   K  — | ]  }|j                  «       d k(  sŒ|–— Œ y­w)ÚlabelsN©Úlower©r?   Úkeys     r    rA   z1_find_labels_default_heuristic.<locals>.<genexpr>„   s   è ø€ ÒU S¸S¿Y¹Y»[ÈHÓ=TœSÑUùs   ‚"›"c              3  óF   K  — | ]  }d |j                  «       v sŒ|–— Œ y­w)ÚlabelNrP   rR   s     r    rA   z1_find_labels_default_heuristic.<locals>.<genexpr>‡   s   è ø€ Ò X¨ÀÈCÏIÉIËKÒAW¤Ñ Xùs   ‚!š!z²Could not infer where the labels are in the sample. Try passing a callable as the labels_getter parameter?If there are no labels in the sample by design, pass labels_getter=None.)r   r)   r*   r   ÚcollectionsÚabcÚMappingr   r   ÚStopIterationÚnextÚkeys)ÚinputsÚcandidate_keys     r    Ú_find_labels_default_heuristicr^   e   sÿ   € ô  �&œ5¤$˜-Ô(Ø˜‘ˆô �fÔØˆä�fœkŸo™o×5Ñ5Ô6ÜðFØFLÀXÈYðXó
ð 	
ð
 €MÜ	”-Ó	 ñ VÜÑU¨F¯K©K«MÔUÓUˆ÷VàÐÜ”mÓ$ñ 	YÜ Ñ X°·±³Ô XÓXˆM÷	YàÐÜðWó
ð 	
ð
 �-Ñ Ð ÷Vð Vú÷	Yð 	Yús   Á-!C"Â'!C.Ã"C+Ã.C7c                óZ   — | dk(  rt         S t        | «      r| S | €d„ S t        d| › d�«      ‚)NÚdefaultc                 ó   — y r.   © )Ú_s    r    ú<lambda>z&_parse_labels_getter.<locals>.<lambda>—   s   � r"   zGlabels_getter should either be 'default', a callable, or None, but got r<   )r^   Úcallabler   )Úlabels_getters    r    Ú_parse_labels_getterrg   ‘   sB   € Ø˜	Ò!Ü-Ð-Ü	�-Ô	 ØÐØ	Ð	ÙÐäÐbÐcpÐbqÐqrÐsÓtÐtr"   c                óX   — 	 t        d„ | D «       «      S # t        $ r t        d«      ‚w xY w)zgReturn the Bounding Boxes in the input.

    Assumes only one ``BoundingBoxes`` object is present.
    c              3  óV   K  — | ]!  }t        |t        j                  «      sŒ|–— Œ# y ­wr.   )r   r	   ÚBoundingBoxes©r?   Úinpts     r    rA   z%get_bounding_boxes.<locals>.<genexpr>£   s   è ø€ Ò_˜T´J¸tÄZ×E]ÑE]Õ4^”DÑ_ùó   ‚)¢)z*No bounding boxes were found in the sample©rZ   rY   r   ©Úflat_inputss    r    Úget_bounding_boxesrq   œ   s6   € ðGÜÑ_ [Ô_Ó_Ð_øÜò GÜÐEÓFÐFðGúó   ‚ ”)c                óX   — 	 t        d„ | D «       «      S # t        $ r t        d«      ‚w xY w)z^Return the keypoints in the input.

    Assumes only one ``KeyPoints`` object is present.
    c              3  óV   K  — | ]!  }t        |t        j                  «      sŒ|–— Œ# y ­wr.   )r   r	   Ú	KeyPointsrk   s     r    rA   z get_keypoints.<locals>.<genexpr>¯   s   è ø€ Ò[˜T´J¸tÄZ×EYÑEYÕ4Z”DÑ[ùrm   z%No keypoints were found in the samplern   ro   s    r    Úget_keypointsrv   ¨   s6   € ðBÜÑ[ [Ô[Ó[Ð[øÜò BÜÐ@ÓAÐAðBúrr   c           
     ó†  — | D �ch c]^  }t        |t        t        j                  t        j                  j                  t        j
                  f«      rt        t        |«      «      ’Œ` }}|st        d«      ‚t        |«      dkD  r t        dt        t        |«      «      › �«      ‚|j                  «       \  }}}|||fS c c}w )z"Return Channel, Height, and Width.z)No image or video was found in the sampler   z/Found multiple CxHxW dimensions in the sample: )Ú
check_typer   r	   ÚImageÚPILÚVideor)   r   r   r   r   r
   ÚsortedÚpop)rp   rl   ÚchwsÚcÚhÚws         r    Ú	query_chwr‚   ´   s°   € ð  öàÜ�dœ^¬Z×-=Ñ-=¼s¿y¹y¿¹ÔPZ×P`ÑP`ÐaÔbô 	Œn˜TÓ"Õ#ð€Dð ñ
 ÜÐCÓDÐDÜ	ˆT‹�QŠÜÐJÌ?Ô[aÐbfÓ[gÓKhÐJiÐjÓkÐkØ�h‰h‹j�G€A€qˆ!Øˆa�ˆ7€Nùòs   …A#B>c                óÜ  — | D �ch c]‹  }t        |t        t        j                  t        j                  j                  t        j
                  t        j                  t        j                  t        j                  f«      rt        t        |«      «      ’Œ� }}|st        d«      ‚t        |«      dkD  r t        dt        t        |«      «      › �«      ‚|j!                  «       \  }}||fS c c}w )zReturn Height and Width.zGNo image, video, mask, bounding box of keypoint was found in the sampler   z-Found multiple HxW dimensions in the sample: )rx   r   r	   ry   rz   r{   ÚMaskrj   ru   r)   r   r   r   r   r
   r|   r}   )rp   rl   Úsizesr€   r�   s        r    Ú
query_sizer†   Ã   sÌ   € ð  öàÜØäÜ× Ñ Ü—	‘	—‘Ü× Ñ Ü—‘Ü×(Ñ(Ü×$Ñ$ðô
ô 	Œh�t‹nÕð€Eð ñ  ÜÐaÓbÐbÜ	ˆU‹�aŠÜÐHÌÔY_Ð`eÓYfÓIgÐHhÐiÓjÐjØ�9‰9‹;�D€A€qØˆaˆ4€Kùò+s   …BC)c                ód   — |D ]+  }t        |t        «      rt        | |«      sŒ  y || «      sŒ+ y y©NTF©r   r   )ÚobjÚtypes_or_checksÚtype_or_checks      r    rx   rx   Ý   s<   € Ø(ò ˆÜ-7¸ÄtÔ-LŒ:�c˜=Õ)Ùñ S`Ð`cÕRdÙðð r"   c                ó.   — | D ]  }t        ||«      sŒ y yrˆ   )rx   )rp   r‹   rl   s      r    Úhas_anyrŽ   ä   s#   € Øò ˆÜ�d˜OÕ,Ùðð r"   c                ór   — |D ]2  }| D ]*  }t        |t        «      rt        ||«      sŒ n	 ||«      sŒ* Œ1  y y)NFTr‰   )rp   r‹   rŒ   rl   s       r    Úhas_allr�   ë   sI   € Ø(ò ˆØò 	ˆDÜ2<¸]ÌDÔ2QŒz˜$ Ö.ÑWdÐeiÕWjÙð	ñ ðð r"   )r   z#int | float | Sequence[int | float]r   ÚstrÚreturnzSequence[float])r+   ú'_FillType | dict[type | str, _FillType]r’   ÚNone)r+   r   r’   r   )r+   r“   r’   zdict[type | str, _FillTypeJIT])rC   zint | Sequence[int]r’   r”   )rK   z3Literal['constant', 'edge', 'reflect', 'symmetric']r’   r”   )r\   r   r’   ztorch.Tensor)rf   z!str | Callable[[Any], Any] | Noner’   zCallable[[Any], Any])rp   ú	list[Any]r’   ztv_tensors.BoundingBoxes)rp   r•   r’   ztv_tensors.KeyPoints)rp   r•   r’   ztuple[int, int, int])rp   r•   r’   ztuple[int, int])rŠ   r   r‹   z(tuple[type | Callable[[Any], bool], ...]r’   Úbool)rp   r•   r‹   ztype | Callable[[Any], bool]r’   r–   ).Ú
__future__r   Úcollections.abcrV   r'   r   Ú
contextlibr   Útypingr   r   r   Ú	PIL.Imagerz   ÚtorchÚtorchvisionr	   Útorchvision._utilsr
   Ú!torchvision.transforms.transformsr   r   r   Ú$torchvision.transforms.v2.functionalr   r   r   Ú+torchvision.transforms.v2.functional._utilsr   r   r!   r&   r0   r5   r:   rE   rL   r^   rg   rq   rv   r‚   r†   rx   rŽ   r�   rb   r"   r    ú<module>r¢      sŒ   ðÝ "ã Û Ý $Ý ç )Ñ )ã Û å "å .ç ^Ñ ^ß YÑ Yß Oóó(nó
ó3òpó"ó_ó
)!óXuó	Gó	Bóóó4óôr"   