ó
    Eñiü ã                   óp  • S SK r S SKrS SKrS SKJr  S SKJrJrJrJ	r	J
r
  S SKrS SKrS SKJrJr  S SKJr  S SKJr  S SKJrJrJr  S SKJr  S	S
KJr  S	SKJ r J!r!J"r"J#r#J$r$J%r%J&r&J'r'J(r(J)r)J*r*J+r+J,r,   " S S\5      r- " S S\5      r. " S S\5      r/ " S S\5      r0 " S S\5      r1 " S S\5      r2 " S S\5      r3 " S S\5      r4 " S S\5      r5 " S S\5      r6 " S  S!\5      r7 " S" S#\5      r8 " S$ S%\5      r9 " S& S'\5      r: " S( S)\5      r; " S* S+\5      r< " S, S-\5      r= " S. S/\5      r>g)0é    N)ÚSequence)ÚAnyÚCallableÚLiteralÚOptionalÚUnion)Ú
transformsÚ
tv_tensors)Úbox_iou)Ú_get_perspective_coeffs)Ú
functionalÚInterpolationModeÚ	Transform)Ú	_FillTypeé   )Ú_RandomApplyTransform)Ú_check_padding_argÚ_check_padding_mode_argÚ_check_sequence_inputÚ	_get_fillÚ_setup_angleÚ_setup_fill_argÚ_setup_number_or_seqÚ_setup_sizeÚget_bounding_boxesÚhas_allÚhas_anyÚis_pure_tensorÚ
query_sizec                   óP   • \ rS rSrSr\R                  rS\S\	\
\4   S\4S jrSrg)	ÚRandomHorizontalFlipé"   aù  Horizontally flip the input with a given probability.

If the input is a :class:`torch.Tensor` or a ``TVTensor`` (e.g. :class:`~torchvision.tv_tensors.Image`,
:class:`~torchvision.tv_tensors.Video`, :class:`~torchvision.tv_tensors.BoundingBoxes` etc.)
it can have arbitrary number of leading batch dimensions. For example,
the image can have ``[..., C, H, W]`` shape. A bounding box can have ``[..., 4]`` shape.

Args:
    p (float, optional): probability of the input being flipped. Default value is 0.5
ÚinptÚparamsÚreturnc                 óB   • U R                  [        R                  U5      $ ©N)Ú_call_kernelÚFÚhorizontal_flip©Úselfr#   r$   s      Ú`/home/mande/repo/quber/.venv/lib/python3.13/site-packages/torchvision/transforms/v2/_geometry.pyÚ	transformÚRandomHorizontalFlip.transform0   s   € Ø× Ñ ¤×!2Ñ!2°DÓ9Ð9ó    © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú_transformsr!   Ú_v1_transform_clsr   ÚdictÚstrr.   Ú__static_attributes__r1   r0   r-   r!   r!   "   s7   † ñ	ð $×8Ñ8Ðð:˜cð :¨4°°S°©>ð :¸c÷ :r0   r!   c                   óP   • \ rS rSrSr\R                  rS\S\	\
\4   S\4S jrSrg)	ÚRandomVerticalFlipé4   a÷  Vertically flip the input with a given probability.

If the input is a :class:`torch.Tensor` or a ``TVTensor`` (e.g. :class:`~torchvision.tv_tensors.Image`,
:class:`~torchvision.tv_tensors.Video`, :class:`~torchvision.tv_tensors.BoundingBoxes` etc.)
it can have arbitrary number of leading batch dimensions. For example,
the image can have ``[..., C, H, W]`` shape. A bounding box can have ``[..., 4]`` shape.

Args:
    p (float, optional): probability of the input being flipped. Default value is 0.5
r#   r$   r%   c                 óB   • U R                  [        R                  U5      $ r'   )r(   r)   Úvertical_flipr+   s      r-   r.   ÚRandomVerticalFlip.transformB   s   € Ø× Ñ ¤§¡°$Ó7Ð7r0   r1   N)r2   r3   r4   r5   r6   r7   r=   r8   r   r9   r:   r.   r;   r1   r0   r-   r=   r=   4   s7   † ñ	ð $×6Ñ6Ðð8˜cð 8¨4°°S°©>ð 8¸c÷ 8r0   r=   c                   óÂ   ^ • \ rS rSrSr\R                  r\R                  SS4S\
\\\   S4   S\
\\4   S\\   S\\   S	S4
U 4S
 jjjrS\S\\\4   S	\4S jrSrU =r$ )ÚResizeéF   a)  Resize the input to the given size.

If the input is a :class:`torch.Tensor` or a ``TVTensor`` (e.g. :class:`~torchvision.tv_tensors.Image`,
:class:`~torchvision.tv_tensors.Video`, :class:`~torchvision.tv_tensors.BoundingBoxes` etc.)
it can have arbitrary number of leading batch dimensions. For example,
the image can have ``[..., C, H, W]`` shape. A bounding box can have ``[..., 4]`` shape.

Args:
    size (sequence, int, or None): Desired
        output size.

        - If size is a sequence like (h, w), output size will be matched to this.
        - If size is an int, smaller edge of the image will be matched to this
          number.  i.e, if height > width, then image will be rescaled to
          (size * height / width, size).
        - If size is None, the output shape is determined by the ``max_size``
          parameter.

        .. note::
            In torchscript mode size as single int is not supported, use a sequence of length 1: ``[size, ]``.
    interpolation (InterpolationMode, optional): Desired interpolation enum defined by
        :class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.BILINEAR``.
        If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.NEAREST_EXACT``,
        ``InterpolationMode.BILINEAR`` and ``InterpolationMode.BICUBIC`` are supported.
        The corresponding Pillow integer constants, e.g. ``PIL.Image.BILINEAR`` are accepted as well.
    max_size (int, optional): The maximum allowed for the longer edge of
        the resized image.

        - If ``size`` is an int: if the longer edge of the image is greater
          than ``max_size`` after being resized according to ``size``,
          ``size`` will be overruled so that the longer edge is equal to
          ``max_size``. As a result, the smaller edge may be shorter than
          ``size``. This is only supported if ``size`` is an int (or a
          sequence of length 1 in torchscript mode).
        - If ``size`` is None: the longer edge of the image will be matched
          to max_size.  i.e, if height > width, then image will be rescaled
          to (max_size, max_size * width / height).

        This should be left to ``None`` (default) when ``size`` is a
        sequence.

    antialias (bool, optional): Whether to apply antialiasing.
        It only affects **tensors** with bilinear or bicubic modes and it is
        ignored otherwise: on PIL images, antialiasing is always applied on
        bilinear or bicubic modes; on other modes (for PIL images and
        tensors), antialiasing makes no sense and this parameter is ignored.
        Possible values are:

        - ``True`` (default): will apply antialiasing for bilinear or bicubic modes.
          Other mode aren't affected. This is probably what you want to use.
        - ``False``: will not apply antialiasing for tensors on any mode. PIL
          images are still antialiased on bilinear or bicubic modes, because
          PIL doesn't support no antialias.
        - ``None``: equivalent to ``False`` for tensors and ``True`` for
          PIL images. This value exists for legacy reasons and you probably
          don't want to use it unless you really know what you are doing.

        The default value changed from ``None`` to ``True`` in
        v0.17, for the PIL and Tensor backends to be consistent.
NTÚsizeÚinterpolationÚmax_sizeÚ	antialiasr%   c                 óR  >• [         TU ]  5         [        U[        5      (       a  U/nOg[        U[        5      (       a  [        U5      S;   a  [        U5      nO7Uc%  [        U[        5      (       d  [        SU S35      eO[        SU S35      eXl        X l	        X0l
        X@l        g )N>   r   é   z7max_size must be an integer when size is None, but got z	 instead.zLsize can be an integer, a sequence of one or two integers, or None, but got )ÚsuperÚ__init__Ú
isinstanceÚintr   ÚlenÚlistÚ
ValueErrorrE   rF   rG   rH   )r,   rE   rF   rG   rH   Ú	__class__s        €r-   rL   ÚResize.__init__†   s©   ø€ ô 	‰ÑÔä�dœC× Ñ Ø�6‰DÜ˜œh×'Ñ'¬C°«I¸Ó,?Ü˜“:‰DØ‰\Ü˜h¬×,Ñ,Ü Ð#ZÐ[cÐZdÐdmÐ!nÓoÐoð -ô Ø^Ð_cÐ^dÐdmÐnóð ð Œ	à*ÔØ ŒØ"�r0   r#   r$   c           	      ó–   • U R                  [        R                  UU R                  U R                  U R
                  U R                  S9$ )N)rF   rG   rH   )r(   r)   ÚresizerE   rF   rG   rH   r+   s      r-   r.   ÚResize.transform    sB   € Ø× Ñ Ü�H‰HØØ�I‰IØ×,Ñ,Ø—]‘]Ø—n‘nð !ð 
ð 	
r0   )rH   rF   rG   rE   )r2   r3   r4   r5   r6   r7   rC   r8   r   ÚBILINEARr   rN   r   r   ÚboolrL   r   r9   r:   r.   r;   Ú__classcell__©rR   s   @r-   rC   rC   F   s­   ø† ñ;ðz $×*Ñ*Ðð
 8I×7QÑ7QØ"&Ø$(ñ#à�C˜ #™¨Ð,Ñ-ð#ð Ð.°Ð3Ñ4ð#ð ˜3‘-ð	#ð
 ˜D‘>ð#ð 
÷#ð #ð4
˜cð 
¨4°°S°©>ð 
¸c÷ 
ò 
r0   rC   c                   ó|   ^ • \ rS rSrSr\R                  rS\\	\
\	   4   4U 4S jjrS\S\\\4   S\4S jrS	rU =r$ )
Ú
CenterCropé«   aì  Crop the input at the center.

If the input is a :class:`torch.Tensor` or a ``TVTensor`` (e.g. :class:`~torchvision.tv_tensors.Image`,
:class:`~torchvision.tv_tensors.Video`, :class:`~torchvision.tv_tensors.BoundingBoxes` etc.)
it can have arbitrary number of leading batch dimensions. For example,
the image can have ``[..., C, H, W]`` shape. A bounding box can have ``[..., 4]`` shape.

If image size is smaller than output size along any edge, image is padded with 0 and then center cropped.

Args:
    size (sequence or int): Desired output size of the crop. If size is an
        int instead of sequence like (h, w), a square crop (size, size) is
        made. If provided a sequence of length 1, it will be interpreted as (size[0], size[0]).
rE   c                 ó@   >• [         TU ]  5         [        USS9U l        g ©Nú3Please provide only two dimensions (h, w) for size.©Ú	error_msg©rK   rL   r   rE   ©r,   rE   rR   s     €r-   rL   ÚCenterCrop.__init__½   ó   ø€ Ü‰ÑÔÜ Ð0eÑfˆ�	r0   r#   r$   r%   c                 óR   • U R                  [        R                  XR                  S9$ )N)Úoutput_size)r(   r)   Úcenter_croprE   r+   s      r-   r.   ÚCenterCrop.transformÁ   s    € Ø× Ñ ¤§¡°Ç)Á)Ð ÐLÐLr0   ©rE   )r2   r3   r4   r5   r6   r7   r\   r8   r   rN   r   rL   r   r9   r:   r.   r;   rY   rZ   s   @r-   r\   r\   «   s^   ø† ñð $×.Ñ.Ððg˜U 3¨°©Ð#5Ñ6÷ gðM˜cð M¨4°°S°©>ð M¸c÷ Mò Mr0   r\   c                   óö   ^ • \ rS rSrSr\R                  rSS\R                  S4S\
\\\   4   S\\\4   S\\\4   S	\
\\4   S
\\   SS4U 4S jjjrS\\   S\\\4   4S jrS\S\\\4   S\4S jrSrU =r$ )ÚRandomResizedCropéÅ   aŠ  Crop a random portion of the input and resize it to a given size.

If the input is a :class:`torch.Tensor` or a ``TVTensor`` (e.g. :class:`~torchvision.tv_tensors.Image`,
:class:`~torchvision.tv_tensors.Video`, :class:`~torchvision.tv_tensors.BoundingBoxes` etc.)
it can have arbitrary number of leading batch dimensions. For example,
the image can have ``[..., C, H, W]`` shape. A bounding box can have ``[..., 4]`` shape.

A crop of the original input is made: the crop has a random area (H * W)
and a random aspect ratio. This crop is finally resized to the given
size. This is popularly used to train the Inception networks.

Args:
    size (int or sequence): expected output size of the crop, for each edge. If size is an
        int instead of sequence like (h, w), a square output size ``(size, size)`` is
        made. If provided a sequence of length 1, it will be interpreted as (size[0], size[0]).

        .. note::
            In torchscript mode size as single int is not supported, use a sequence of length 1: ``[size, ]``.
    scale (tuple of float, optional): Specifies the lower and upper bounds for the random area of the crop,
        before resizing. The scale is defined with respect to the area of the original image.
    ratio (tuple of float, optional): lower and upper bounds for the random aspect ratio of the crop, before
        resizing.
    interpolation (InterpolationMode, optional): Desired interpolation enum defined by
        :class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.BILINEAR``.
        If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.NEAREST_EXACT``,
        ``InterpolationMode.BILINEAR`` and ``InterpolationMode.BICUBIC`` are supported.
        The corresponding Pillow integer constants, e.g. ``PIL.Image.BILINEAR`` are accepted as well.
    antialias (bool, optional): Whether to apply antialiasing.
        It only affects **tensors** with bilinear or bicubic modes and it is
        ignored otherwise: on PIL images, antialiasing is always applied on
        bilinear or bicubic modes; on other modes (for PIL images and
        tensors), antialiasing makes no sense and this parameter is ignored.
        Possible values are:

        - ``True`` (default): will apply antialiasing for bilinear or bicubic modes.
          Other mode aren't affected. This is probably what you want to use.
        - ``False``: will not apply antialiasing for tensors on any mode. PIL
          images are still antialiased on bilinear or bicubic modes, because
          PIL doesn't support no antialias.
        - ``None``: equivalent to ``False`` for tensors and ``True`` for
          PIL images. This value exists for legacy reasons and you probably
          don't want to use it unless you really know what you are doing.

        The default value changed from ``None`` to ``True`` in
        v0.17, for the PIL and Tensor backends to be consistent.
)g{®Gáz´?ç      ð?)g      è?gUUUUUUõ?TrE   ÚscaleÚratiorF   rH   r%   Nc                 óú  >• [         TU ]  5         [        USS9U l        [	        U[
        5      (       a  [        U5      S:w  a  [        S5      e[	        U[
        5      (       a  [        U5      S:w  a  [        S5      eUS   US   :”  d  US   US   :”  a  [        R                  " S5        X l
        X0l        X@l        XPl        [        R                  " [        R                   " U R                  5      5      U l        g )	Nr`   ra   rJ   z)Scale should be a sequence of two floats.z)Ratio should be a sequence of two floats.r   r   z,Scale and ratio should be of kind (min, max))rK   rL   r   rE   rM   r   rO   Ú	TypeErrorÚwarningsÚwarnrp   rq   rF   rH   ÚtorchÚlogÚtensorÚ
_log_ratio)r,   rE   rp   rq   rF   rH   rR   s         €r-   rL   ÚRandomResizedCrop.__init__÷   sÃ   ø€ ô 	‰ÑÔÜ Ð0eÑfˆŒ	ä˜%¤×*Ñ*¬c°%«j¸A«oÜÐGÓHÐHÜ˜%¤×*Ñ*¬c°%«j¸A«oÜÐGÓHÐHØ�!‰H�u˜Q‘xÓ U¨1¡X°°a±Ó%8Ü�MŠMÐHÔIàŒ
ØŒ
Ø*ÔØ"ŒäŸ)š)¤E§L¢L°·±Ó$<Ó=ˆ�r0   Úflat_inputsc           	      ó¾  • [        U5      u  p#X#-  nU R                  n[        S5       GHr  nU[        R                  " S5      R                  U R                  S   U R                  S   5      R                  5       -  n[        R                  " [        R                  " S5      R                  US   US   5      5      R                  5       n[        [        [        R                  " Xx-  5      5      5      n	[        [        [        R                  " Xx-  5      5      5      n
SU	s=:  a	  U::  d  GM  O  GM  SU
s=:  a	  U::  d  GM  O  GM!  [        R                  " SX*-
  S-   SS9R                  5       n[        R                  " SX9-
  S-   SS9R                  5       n  O·   [        U5      [        U5      -  nU[        U R                   5      :  a-  Un	[        [        U	[        U R                   5      -  5      5      n
OJU[#        U R                   5      :”  a-  Un
[        [        U
[#        U R                   5      -  5      5      n	OUn	Un
X*-
  S-  nX9-
  S-  n[%        X¼X©S9$ )Né
   r   r   ©r   rk   rJ   ©ÚtopÚleftÚheightÚwidth)r   ry   Úrangerv   ÚemptyÚuniform_rp   ÚitemÚexprN   ÚroundÚmathÚsqrtÚrandintÚfloatÚminrq   Úmaxr9   )r,   r{   r‚   rƒ   ÚareaÚ	log_ratioÚ_Útarget_areaÚaspect_ratioÚwÚhÚiÚjÚin_ratios                 r-   Úmake_paramsÚRandomResizedCrop.make_params  sÞ  € Ü" ;Ó/‰ˆØ‰~ˆà—O‘Oˆ	Ü�r—ˆAØ¤§¢¨Q£×!8Ñ!8¸¿¹ÀA¹ÈÏ
É
ÐSTÉÓ!V×![Ñ![Ó!]Ñ]ˆKÜ Ÿ9š9Ü—’˜A“×'Ñ'Ø˜a‘LØ˜a‘Lóó÷
 ‰d‹fð ô ”Eœ$Ÿ)š) KÑ$>Ó?Ó@ÓAˆAÜ”Eœ$Ÿ)š) KÑ$>Ó?Ó@ÓAˆAà�1�~˜�~‹~ ! a¥/¨6§/£/Ü—M’M ! V¡Z°!¡^¸$Ñ?×DÑDÓF�Ü—M’M ! U¡Y°¡]¸Ñ>×CÑCÓE�Ùñ ô$ ˜U“|¤e¨F£mÑ3ˆHØœ#˜dŸj™j›/Ó)Ø�Üœ˜a¤# d§j¡j£/Ñ1Ó2Ó3‘ØœC §
¡
›OÓ+Ø�Üœ˜a¤# d§j¡j£/Ñ1Ó2Ó3‘à�Ø�Ø‘ Ñ!ˆAØ‘˜qÑ ˆAä˜¨!Ñ5Ð5r0   r#   r$   c                 óŽ   • U R                   " [        R                  U40 UDU R                  U R                  U R
                  S.D6$ )N©rE   rF   rH   )r(   r)   Úresized_croprE   rF   rH   r+   s      r-   r.   ÚRandomResizedCrop.transform6  sC   € Ø× Ò Ü�N‰N˜Dñ
Ø$*ð
Ø15·±È$×J\ÑJ\Ðhl×hvÑhvó
ð 	
r0   )ry   rH   rF   rq   rp   rE   )r2   r3   r4   r5   r6   r7   rm   r8   r   rW   r   rN   r   Útupler�   r   rX   rL   rP   r   r9   r:   rš   r.   r;   rY   rZ   s   @r-   rm   rm   Å   så   ø† ñ-ð^ $×5Ñ5Ðð
 &1Ø%;Ø7H×7QÑ7QØ$(ñ>à�C˜ #™Ð&Ñ'ð>ð �U˜E�\Ñ"ð>ð �U˜E�\Ñ"ð	>ð
 Ð.°Ð3Ñ4ð>ð ˜D‘>ð>ð 
÷>ð >ð2$6 t¨C¡yð $6°T¸#¸s¸(±^ô $6ðL
˜cð 
¨4°°S°©>ð 
¸c÷ 
ò 
r0   rm   c            
       ó¼   ^ • \ rS rSrSr\R                  rS\\	\
\	   4   SS4U 4S jjrS\S\S	\S
\S\4
U 4S jjrS\S\\\4   S\4S jrS\\   SS4S jrSrU =r$ )ÚFiveCropi<  ay  Crop the image or video into four corners and the central crop.

If the input is a :class:`torch.Tensor` or a :class:`~torchvision.tv_tensors.Image` or a
:class:`~torchvision.tv_tensors.Video` it can have arbitrary number of leading batch dimensions.
For example, the image can have ``[..., C, H, W]`` shape.

.. Note::
     This transform returns a tuple of images and there may be a mismatch in the number of
     inputs and targets your Dataset returns. See below for an example of how to deal with
     this.

Args:
     size (sequence or int): Desired output size of the crop. If size is an ``int``
        instead of sequence like (h, w), a square crop of size (size, size) is made.
        If provided a sequence of length 1, it will be interpreted as (size[0], size[0]).

Example:
    >>> class BatchMultiCrop(transforms.Transform):
    ...     def forward(self, sample: Tuple[Tuple[Union[tv_tensors.Image, tv_tensors.Video], ...], int]):
    ...         images_or_videos, labels = sample
    ...         batch_size = len(images_or_videos)
    ...         image_or_video = images_or_videos[0]
    ...         images_or_videos = tv_tensors.wrap(torch.stack(images_or_videos), like=image_or_video)
    ...         labels = torch.full((batch_size,), label, device=images_or_videos.device)
    ...         return images_or_videos, labels
    ...
    >>> image = tv_tensors.Image(torch.rand(3, 256, 256))
    >>> label = 3
    >>> transform = transforms.Compose([transforms.FiveCrop(224), BatchMultiCrop()])
    >>> images, labels = transform(image, label)
    >>> images.shape
    torch.Size([5, 3, 224, 224])
    >>> labels
    tensor([3, 3, 3, 3, 3])
rE   r%   Nc                 ó@   >• [         TU ]  5         [        USS9U l        g r_   rc   rd   s     €r-   rL   ÚFiveCrop.__init__c  rf   r0   r   r#   ÚargsÚkwargsc                 ó,  >• [        U[        R                  [        R                  [        R                  45      (       aB  [
        R                  " [        U 5      R                   S[        U5      R                   S35        [        TU ](  " X/UQ70 UD6$ ©Nz:() is currently passing through inputs of type tv_tensors.z(. This will likely change in the future.©rM   r
   ÚBoundingBoxesÚ	KeyPointsÚMaskrt   ru   Útyper2   rK   r(   ©r,   r   r#   r¥   r¦   rR   s        €r-   r(   ÚFiveCrop._call_kernelg  ó}   ø€ Ü�dœZ×5Ñ5´z×7KÑ7KÌZÏ_É_Ð]×^Ñ^Ü�MŠMÜ˜“:×&Ñ&Ð'ð (Ü" 4›j×1Ñ1Ð2Ð2Zð\ôô ‰wÒ# JÐF°tÒF¸vÑFÐFr0   r$   c                 óV   • U R                  [        R                  XR                  5      $ r'   )r(   r)   Ú	five_croprE   r+   s      r-   r.   ÚFiveCrop.transformo  s   € Ø× Ñ ¤§¡¨d·I±IÓ>Ð>r0   r{   c                 ó¤   • [        U[        R                  [        R                  5      (       a"  [	        S[        U 5      R                   S35      eg ©Nz1BoundingBoxes'es and Mask's are not supported by z()©r   r
   rª   r¬   rs   r­   r2   ©r,   r{   s     r-   Úcheck_inputsÚFiveCrop.check_inputsr  óE   € Ü�;¤
× 8Ñ 8¼*¿/¹/×JÑJÜÐOÔPTÐUYÓPZ×PcÑPcÐOdÐdfÐgÓhÐhð Kr0   rk   )r2   r3   r4   r5   r6   r7   r¢   r8   r   rN   r   rL   r   r   r(   r9   r:   r.   rP   r¸   r;   rY   rZ   s   @r-   r¢   r¢   <  s­   ø† ñ"ðH $×,Ñ,Ððg˜U 3¨°©Ð#5Ñ6ð g¸4÷ gðG xð G°sð GÀ3ð GÐRUð GÐZ]÷ Gð?˜cð ?¨4°°S°©>ð ?¸cô ?ði¨¨S©	ð i°d÷ iò ir0   r¢   c            
       óÄ   ^ • \ rS rSrSr\R                  rSS\\	\
\	   4   S\SS4U 4S jjjrS\S	\S
\S\S\4
U 4S jjrS\\   SS4S jrS	\S\\\4   S\4S jrSrU =r$ )ÚTenCropiw  aÛ  Crop the image or video into four corners and the central crop plus the flipped version of
these (horizontal flipping is used by default).

If the input is a :class:`torch.Tensor` or a :class:`~torchvision.tv_tensors.Image` or a
:class:`~torchvision.tv_tensors.Video` it can have arbitrary number of leading batch dimensions.
For example, the image can have ``[..., C, H, W]`` shape.

See :class:`~torchvision.transforms.v2.FiveCrop` for an example.

.. Note::
     This transform returns a tuple of images and there may be a mismatch in the number of
     inputs and targets your Dataset returns. See below for an example of how to deal with
     this.

Args:
    size (sequence or int): Desired output size of the crop. If size is an
        int instead of sequence like (h, w), a square crop (size, size) is
        made. If provided a sequence of length 1, it will be interpreted as (size[0], size[0]).
    vertical_flip (bool, optional): Use vertical flipping instead of horizontal
rE   r@   r%   Nc                 óL   >• [         TU ]  5         [        USS9U l        X l        g r_   )rK   rL   r   rE   r@   )r,   rE   r@   rR   s      €r-   rL   ÚTenCrop.__init__�  s#   ø€ Ü‰ÑÔÜ Ð0eÑfˆŒ	Ø*Õr0   r   r#   r¥   r¦   c                 ó,  >• [        U[        R                  [        R                  [        R                  45      (       aB  [
        R                  " [        U 5      R                   S[        U5      R                   S35        [        TU ](  " X/UQ70 UD6$ r¨   r©   r®   s        €r-   r(   ÚTenCrop._call_kernel”  r°   r0   r{   c                 ó¤   • [        U[        R                  [        R                  5      (       a"  [	        S[        U 5      R                   S35      eg rµ   r¶   r·   s     r-   r¸   ÚTenCrop.check_inputsœ  rº   r0   r$   c                 óh   • U R                  [        R                  XR                  U R                  S9$ )N)r@   )r(   r)   Úten_croprE   r@   r+   s      r-   r.   ÚTenCrop.transform   s(   € Ø× Ñ ¤§¡¨T·9±9ÈD×L^ÑL^Ð Ð_Ð_r0   )rE   r@   )F)r2   r3   r4   r5   r6   r7   r¼   r8   r   rN   r   rX   rL   r   r   r(   rP   r¸   r9   r:   r.   r;   rY   rZ   s   @r-   r¼   r¼   w  sº   ø† ñð* $×+Ñ+Ðñ+˜U 3¨°©Ð#5Ñ6ð +Àtð +ÐX\÷ +ð +ð
G xð G°sð GÀ3ð GÐRUð GÐZ]÷ Gði¨¨S©	ð i°dô ið`˜cð `¨4°°S°©>ð `¸c÷ `ò `r0   r¼   c            
       óÒ   ^ • \ rS rSrSr\R                  rS\\	\
4   4U 4S jjr  SS\\\\   4   S\\\\\\	4   \4   4   S\S   SS	4U 4S
 jjjrS\
S\\	\
4   S\
4S jrSrU =r$ )ÚPadi¤  a<  Pad the input on all sides with the given "pad" value.

If the input is a :class:`torch.Tensor` or a ``TVTensor`` (e.g. :class:`~torchvision.tv_tensors.Image`,
:class:`~torchvision.tv_tensors.Video`, :class:`~torchvision.tv_tensors.BoundingBoxes` etc.)
it can have arbitrary number of leading batch dimensions. For example,
the image can have ``[..., C, H, W]`` shape. A bounding box can have ``[..., 4]`` shape.

Args:
    padding (int or sequence): Padding on each border. If a single int is provided this
        is used to pad all borders. If sequence of length 2 is provided this is the padding
        on left/right and top/bottom respectively. If a sequence of length 4 is provided
        this is the padding for the left, top, right and bottom borders respectively.

        .. note::
            In torchscript mode padding as single int is not supported, use a sequence of
            length 1: ``[padding, ]``.
    fill (number or tuple or dict, optional): Pixel fill value used when the  ``padding_mode`` is constant.
        Default is 0. If a tuple of length 3, it is used to fill R, G, B channels respectively.
        Fill value can be also a dictionary mapping data type to the fill value, e.g.
        ``fill={tv_tensors.Image: 127, tv_tensors.Mask: 0}`` where ``Image`` will be filled with 127 and
        ``Mask`` will be filled with 0.
    padding_mode (str, optional): Type of padding. Should be: constant, edge, reflect or symmetric.
        Default is "constant".

        - constant: pads with a constant value, this value is specified with fill

        - edge: pads with the last value at the edge of the image.

        - reflect: pads with reflection of image without repeating the last value on the edge.
          For example, padding [1, 2, 3, 4] with 2 elements on both sides in reflect mode
          will result in [3, 2, 1, 2, 3, 4, 3, 2]

        - symmetric: pads with reflection of image repeating the last value on the edge.
          For example, padding [1, 2, 3, 4] with 2 elements on both sides in symmetric mode
          will result in [2, 1, 1, 2, 3, 4, 4, 3]
r%   c                 óÈ   >• [         TU ]  5       nUS   bL  [        US   [        [        45      (       d.  [        [        U 5      R                   SU R                   S35      eU$ )NÚfillú5() can only be scripted for a scalar `fill`, but got Ú.)	rK   Ú _extract_params_for_v1_transformrM   rN   r�   rQ   r­   r2   rÉ   )r,   r$   rR   s     €r-   rÌ   Ú$Pad._extract_params_for_v1_transformÌ  s`   ø€ Ü‘Ñ9Ó;ˆà�v‘Ñ&¬*°V¸F±^ÄcÌ5À\×*RÑ*RÜ¤ T£
× 3Ñ 3Ð4Ð4iÐjn×jsÑjsÐitÐtuÐvÓwÐwàˆr0   ÚpaddingrÉ   Úpadding_mode©ÚconstantÚedgeÚreflectÚ	symmetricNc                 óÒ   >• [         TU ]  5         [        U5        [        U5        [	        U[
        5      (       d  [        U5      nXl        X l        [        U5      U l
        X0l        g r'   )rK   rL   r   r   rM   rN   rP   rÎ   rÉ   r   Ú_fillrÏ   )r,   rÎ   rÉ   rÏ   rR   s       €r-   rL   ÚPad.__init__Ô  sT   ø€ ô 	‰ÑÔä˜7Ô#Ü Ô-ô ˜'¤3×'Ñ'Ü˜7“mˆGØŒØŒ	Ü$ TÓ*ˆŒ
Ø(Õr0   r#   r$   c                 ó¦   • [        U R                  [        U5      5      nU R                  [        R
                  XR                  X0R                  S9$ )N©rÎ   rÉ   rÏ   )r   rÖ   r­   r(   r)   ÚpadrÎ   rÏ   ©r,   r#   r$   rÉ   s       r-   r.   ÚPad.transformç  s<   € Ü˜Ÿ™¤T¨$£ZÓ0ˆØ× Ñ ¤§¡¨·l±lÈ×\mÑ\mÐ ÐnÐnr0   )rÖ   rÉ   rÎ   rÏ   )r   rÑ   )r2   r3   r4   r5   r6   r7   rÇ   r8   r9   r:   r   rÌ   r   rN   r   r   r­   r   rL   r.   r;   rY   rZ   s   @r-   rÇ   rÇ   ¤  sÀ   ø† ñ#ðJ $Ÿ™Ðð°$°s¸C°x±.÷ ð EFØLVñ	)à�s˜H S™MÐ)Ñ*ð)ð �I˜t E¨$°¨)Ñ$4°iÐ$?Ñ@Ð@ÑAð)ð ÐHÑIð	)ð
 
÷)ð )ð&o˜cð o¨4°°S°©>ð o¸c÷ oò or0   rÇ   c            	       ó°   ^ • \ rS rSrSr   SS\\\\\\	4   \4   4   S\
\   S\SS4U 4S jjjrS	\\   S\\	\4   4S
 jrS\S\\	\4   S\4S jrSrU =r$ )ÚRandomZoomOutiì  aÛ  "Zoom out" transformation from
`"SSD: Single Shot MultiBox Detector" <https://arxiv.org/abs/1512.02325>`_.

This transformation randomly pads images, videos, bounding boxes and masks creating a zoom out effect.
Output spatial size is randomly sampled from original size up to a maximum size configured
with ``side_range`` parameter:

.. code-block:: python

    r = uniform_sample(side_range[0], side_range[1])
    output_width = input_width * r
    output_height = input_height * r

If the input is a :class:`torch.Tensor` or a ``TVTensor`` (e.g. :class:`~torchvision.tv_tensors.Image`,
:class:`~torchvision.tv_tensors.Video`, :class:`~torchvision.tv_tensors.BoundingBoxes` etc.)
it can have arbitrary number of leading batch dimensions. For example,
the image can have ``[..., C, H, W]`` shape. A bounding box can have ``[..., 4]`` shape.

Args:
    fill (number or tuple or dict, optional): Pixel fill value used when the  ``padding_mode`` is constant.
        Default is 0. If a tuple of length 3, it is used to fill R, G, B channels respectively.
        Fill value can be also a dictionary mapping data type to the fill value, e.g.
        ``fill={tv_tensors.Image: 127, tv_tensors.Mask: 0}`` where ``Image`` will be filled with 127 and
        ``Mask`` will be filled with 0.
    side_range (sequence of floats, optional): tuple of two floats defines minimum and maximum factors to
        scale the input size.
    p (float, optional): probability that the zoom operation will be performed.
rÉ   Ú
side_rangeÚpr%   Nc                 ó¶   >• [         TU ]  US9  Xl        [        U5      U l        [        USSS9  X l        US   S:  d  US   US   :”  a  [        SU S	35      eg )
N©rà   rß   ©rJ   ©Ú	req_sizesr   ro   r   zInvalid side range provided rË   )rK   rL   rÉ   r   rÖ   r   rß   rQ   )r,   rÉ   rß   rà   rR   s       €r-   rL   ÚRandomZoomOut.__init__
  sm   ø€ ô 	‰Ñ˜1ÐÑàŒ	Ü$ TÓ*ˆŒ
ä˜j¨,À$ÒGà$ŒØ�a‰=˜3Ó *¨Q¡-°*¸Q±-Ó"?ÜÐ;¸J¸<ÀqÐIÓJÐJð #@r0   r{   c                 óŠ  • [        U5      u  p#U R                  S   [        R                  " S5      U R                  S   U R                  S   -
  -  -   n[	        X4-  5      n[	        X$-  5      n[        R                  " S5      n[	        XS-
  US   -  5      n[	        Xb-
  US   -  5      nXWU-   -
  n	XhU-   -
  n
XxXš/n[        US9$ )Nr   r   rJ   )rÎ   )r   rß   rv   ÚrandrN   r9   )r,   r{   Úorig_hÚorig_wÚrÚcanvas_widthÚcanvas_heightr�   r€   ÚrightÚbottomrÎ   s               r-   rš   ÚRandomZoomOut.make_params  sÂ   € Ü# KÓ0‰ˆà�O‰O˜AÑ¤§¢¨A£°$·/±/À!Ñ2DÀtÇÁÐWXÑGYÑ2YÑ!ZÑZˆÜ˜6™:“ˆÜ˜F™J›ˆä�JŠJ�q‹MˆÜ�LÑ)¨Q¨q©TÑ1Ó2ˆÜ�=Ñ)¨Q¨q©TÑ1Ó2ˆØ v¡Ñ.ˆØ¨¡,Ñ/ˆØ˜eÐ,ˆä˜GÑ$Ð$r0   r#   r$   c                 óŒ   • [        U R                  [        U5      5      nU R                  " [        R
                  U40 UDSU0D6$ )NrÉ   )r   rÖ   r­   r(   r)   rÚ   rÛ   s       r-   r.   ÚRandomZoomOut.transform+  s7   € Ü˜Ÿ™¤T¨$£ZÓ0ˆØ× Ò ¤§¡¨ÑB°ÑB¸TÒBÐBr0   )rÖ   rÉ   rß   )r   )ro   g      @ç      à?)r2   r3   r4   r5   r6   r   r   r9   r­   r:   r   r�   rL   rP   r   rš   r.   r;   rY   rZ   s   @r-   rÞ   rÞ   ì  s·   ø† ñð> EFØ&0Øñ	Kà�I˜t E¨$°¨)Ñ$4°iÐ$?Ñ@Ð@ÑAðKð ˜U‘OðKð ð	Kð
 
÷Kð Kð"% t¨C¡yð %°T¸#¸s¸(±^ô %ð C˜cð C¨4°°S°©>ð C¸c÷ Cò Cr0   rÞ   c                   ó  ^ • \ rS rSrSr\R                  r\R                  SSS4S\
\R                  \4   S\
\\4   S\S	\\\      S
\
\\\
\\4   \4   4   SS4U 4S jjjrS\\   S\\\4   4S jrS\S\\\4   S\4S jrSrU =r$ )ÚRandomRotationi0  a†	  Rotate the input by angle.

If the input is a :class:`torch.Tensor` or a ``TVTensor`` (e.g. :class:`~torchvision.tv_tensors.Image`,
:class:`~torchvision.tv_tensors.Video`, :class:`~torchvision.tv_tensors.BoundingBoxes` etc.)
it can have arbitrary number of leading batch dimensions. For example,
the image can have ``[..., C, H, W]`` shape. A bounding box can have ``[..., 4]`` shape.

Args:
    degrees (sequence or number): Range of degrees to select from.
        If degrees is a number instead of sequence like (min, max), the range of degrees
        will be [-degrees, +degrees].
    interpolation (InterpolationMode, optional): Desired interpolation enum defined by
        :class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.NEAREST``.
        If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported.
        The corresponding Pillow integer constants, e.g. ``PIL.Image.BILINEAR`` are accepted as well.
    expand (bool, optional): Optional expansion flag.
        If true, expands the output to make it large enough to hold the entire rotated image.
        If false or omitted, make the output image the same size as the input image.
        Note that the expand flag assumes rotation around the center (see note below) and no translation.
    center (sequence, optional): Optional center of rotation, (x, y). Origin is the upper left corner.
        Default is the center of the image.

        .. note::

            In theory, setting ``center`` has no effect if ``expand=True``, since the image center will become the
            center of rotation. In practice however, due to numerical precision, this can lead to off-by-one
            differences of the resulting image size compared to using the image center in the first place. Thus, when
            setting ``expand=True``, it's best to leave ``center=None`` (default).
    fill (number or tuple or dict, optional): Pixel fill value used when the  ``padding_mode`` is constant.
        Default is 0. If a tuple of length 3, it is used to fill R, G, B channels respectively.
        Fill value can be also a dictionary mapping data type to the fill value, e.g.
        ``fill={tv_tensors.Image: 127, tv_tensors.Mask: 0}`` where ``Image`` will be filled with 127 and
        ``Mask`` will be filled with 0.

.. _filters: https://pillow.readthedocs.io/en/latest/handbook/concepts.html#filters

FNr   ÚdegreesrF   ÚexpandÚcenterrÉ   r%   c                 ó®   >• [         TU ]  5         [        USSS9U l        X l        X0l        XPl        [        U5      U l        Ub  [        USSS9  X@l
        g )Nrö   rã   ©Únamerå   rø   rä   )rK   rL   r   rö   rF   r÷   rÉ   r   rÖ   r   rø   )r,   rö   rF   r÷   rø   rÉ   rR   s         €r-   rL   ÚRandomRotation.__init__Y  sS   ø€ ô 	‰ÑÔÜ# G°)ÀtÑLˆŒØ*ÔØŒàŒ	Ü$ TÓ*ˆŒ
àÑÜ! &¨(¸dÒCà�r0   r{   c                 ó°   • [         R                  " S5      R                  U R                  S   U R                  S   5      R	                  5       n[        US9$ )Nr   r   )Úangle)rv   r…   r†   rö   r‡   r9   )r,   r{   rþ   s      r-   rš   ÚRandomRotation.make_paramsn  s@   € Ü—’˜A“×'Ñ'¨¯©°Q©¸¿¹Àa¹ÓI×NÑNÓPˆÜ˜%Ñ Ð r0   r#   r$   c           	      óÎ   • [        U R                  [        U5      5      nU R                  " [        R
                  U40 UDU R                  U R                  U R                  US.D6$ )N)rF   r÷   rø   rÉ   )	r   rÖ   r­   r(   r)   ÚrotaterF   r÷   rø   rÛ   s       r-   r.   ÚRandomRotation.transformr  s^   € Ü˜Ÿ™¤T¨$£ZÓ0ˆØ× Ò Ü�H‰HØñ
ð ð
ð ×,Ñ,Ø—;‘;Ø—;‘;Øó
ð 	
r0   )rÖ   rø   rö   r÷   rÉ   rF   )r2   r3   r4   r5   r6   r7   rõ   r8   r   ÚNEARESTr   ÚnumbersÚNumberr   rN   rX   r   rP   r�   r   r9   r­   r:   rL   r   rš   r.   r;   rY   rZ   s   @r-   rõ   rõ   0  sõ   ø† ñ$ðL $×2Ñ2Ðð
 8I×7PÑ7PØØ(,ØDEñà�w—~‘~ xÐ/Ñ0ðð Ð.°Ð3Ñ4ðð ð	ð
 ˜˜e™Ñ%ðð �I˜t E¨$°¨)Ñ$4°iÐ$?Ñ@Ð@ÑAðð 
÷ð ð*! t¨C¡yð !°T¸#¸s¸(±^ô !ð

˜cð 

¨4°°S°©>ð 

¸c÷ 

ò 

r0   rõ   c                   óP  ^ • \ rS rSrSr\R                  rSSS\R                  SS4S\
\R                  \4   S\\\      S\\\      S\\
\\\\   4      S	\
\\4   S
\
\\\
\\4   \4   4   S\\\      SS4U 4S jjjrS\\   S\\\4   4S jrS\S\\\4   S\4S jrSrU =r$ )ÚRandomAffinei  aâ
  Random affine transformation the input keeping center invariant.

If the input is a :class:`torch.Tensor` or a ``TVTensor`` (e.g. :class:`~torchvision.tv_tensors.Image`,
:class:`~torchvision.tv_tensors.Video`, :class:`~torchvision.tv_tensors.BoundingBoxes` etc.)
it can have arbitrary number of leading batch dimensions. For example,
the image can have ``[..., C, H, W]`` shape. A bounding box can have ``[..., 4]`` shape.

Args:
    degrees (sequence or number): Range of degrees to select from.
        If degrees is a number instead of sequence like (min, max), the range of degrees
        will be (-degrees, +degrees). Set to 0 to deactivate rotations.
    translate (tuple, optional): tuple of maximum absolute fraction for horizontal
        and vertical translations. For example translate=(a, b), then horizontal shift
        is randomly sampled in the range -img_width * a < dx < img_width * a and vertical shift is
        randomly sampled in the range -img_height * b < dy < img_height * b. Will not translate by default.
    scale (tuple, optional): scaling factor interval, e.g (a, b), then scale is
        randomly sampled from the range a <= scale <= b. Will keep original scale by default.
    shear (sequence or number, optional): Range of degrees to select from.
        If shear is a number, a shear parallel to the x-axis in the range (-shear, +shear)
        will be applied. Else if shear is a sequence of 2 values a shear parallel to the x-axis in the
        range (shear[0], shear[1]) will be applied. Else if shear is a sequence of 4 values,
        an x-axis shear in (shear[0], shear[1]) and y-axis shear in (shear[2], shear[3]) will be applied.
        Will not apply shear by default.
    interpolation (InterpolationMode, optional): Desired interpolation enum defined by
        :class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.NEAREST``.
        If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported.
        The corresponding Pillow integer constants, e.g. ``PIL.Image.BILINEAR`` are accepted as well.
    fill (number or tuple or dict, optional): Pixel fill value used when the  ``padding_mode`` is constant.
        Default is 0. If a tuple of length 3, it is used to fill R, G, B channels respectively.
        Fill value can be also a dictionary mapping data type to the fill value, e.g.
        ``fill={tv_tensors.Image: 127, tv_tensors.Mask: 0}`` where ``Image`` will be filled with 127 and
        ``Mask`` will be filled with 0.
    center (sequence, optional): Optional center of rotation, (x, y). Origin is the upper left corner.
        Default is the center of the image.

.. _filters: https://pillow.readthedocs.io/en/latest/handbook/concepts.html#filters

Nr   rö   Ú	translaterp   ÚshearrF   rÉ   rø   r%   c                 ó   >• [         T
U ]  5         [        USSS9U l        Ub.  [	        USSS9  U H  nSUs=::  a  S::  a  M  O  [        S5      e   X l        Ub%  [	        US	SS9  U H  n	U	S
::  d  M  [        S5      e   X0l        Ub  [        USSS9U l        OX@l        XPl	        X`l
        [        U5      U l        Ub  [	        USSS9  Xpl        g )Nrö   rã   rú   r  rä   ç        ro   z,translation values should be between 0 and 1rp   r   zscale values should be positiver	  )rJ   é   rø   )rK   rL   r   rö   r   rQ   r  rp   r	  rF   rÉ   r   rÖ   rø   )r,   rö   r  rp   r	  rF   rÉ   rø   ÚtÚsrR   s             €r-   rL   ÚRandomAffine.__init__©  sÙ   ø€ ô 	‰ÑÔÜ# G°)ÀtÑLˆŒØÑ Ü! )¨[ÀDÒIÛ�Ø˜q� CŸÜ$Ð%SÓTÐTñ ð #ŒØÑÜ! %¨¸DÒAÛ�Ø˜•6Ü$Ð%FÓGÐGñ ð Œ
àÑÜ% e°'ÀVÑLˆD�JàŒJà*ÔØŒ	Ü$ TÓ*ˆŒ
àÑÜ! &¨(¸dÒCà�r0   r{   c                 óÆ  • [        U5      u  p#[        R                  " S5      R                  U R                  S   U R                  S   5      R                  5       nU R                  bÈ  [        U R                  S   U-  5      n[        U R                  S   U-  5      n[        [        [        R                  " S5      R                  U* U5      R                  5       5      5      n[        [        [        R                  " S5      R                  U* U5      R                  5       5      5      nXx4n	OSn	U R                  bO  [        R                  " S5      R                  U R                  S   U R                  S   5      R                  5       n
OSn
S=p¼U R                  bµ  [        R                  " S5      R                  U R                  S   U R                  S   5      R                  5       n[        U R                  5      S:X  aN  [        R                  " S5      R                  U R                  S   U R                  S   5      R                  5       nX¼4n[        XIX­S	9$ )
Nr   r   )r   r   ro   r  r  rJ   é   )rþ   r  rp   r	  )r   rv   r…   r†   rö   r‡   r  r�   rN   r‰   rp   r	  rO   r9   )r,   r{   r‚   rƒ   rþ   Úmax_dxÚmax_dyÚtxÚtyr  rp   Úshear_xÚshear_yr	  s                 r-   rš   ÚRandomAffine.make_paramsÐ  sÄ  € Ü" ;Ó/‰ˆä—’˜A“×'Ñ'¨¯©°Q©¸¿¹Àa¹ÓI×NÑNÓPˆØ�>‰>Ñ%Ü˜4Ÿ>™>¨!Ñ,¨uÑ4Ó5ˆFÜ˜4Ÿ>™>¨!Ñ,¨vÑ5Ó6ˆFÜ”Uœ5Ÿ;š; q›>×2Ñ2°F°7¸FÓC×HÑHÓJÓKÓLˆBÜ”Uœ5Ÿ;š; q›>×2Ñ2°F°7¸FÓC×HÑHÓJÓKÓLˆBØ˜‰IàˆIà�:‰:Ñ!Ü—K’K “N×+Ñ+¨D¯J©J°q©M¸4¿:¹:Àa¹=ÓI×NÑNÓP‰EàˆEàÐˆØ�:‰:Ñ!Ü—k’k !“n×-Ñ-¨d¯j©j¸©m¸T¿Z¹ZÈ¹]ÓK×PÑPÓRˆGÜ�4—:‘:‹ !Ó#ÜŸ+š+ a›.×1Ñ1°$·*±*¸Q±-ÀÇÁÈAÁÓO×TÑTÓV�àÐ"ˆÜ˜%¸EÑOÐOr0   r#   r$   c                 ó¸   • [        U R                  [        U5      5      nU R                  " [        R
                  U40 UDU R                  UU R                  S.D6$ )N)rF   rÉ   rø   )r   rÖ   r­   r(   r)   ÚaffinerF   rø   rÛ   s       r-   r.   ÚRandomAffine.transformë  sW   € Ü˜Ÿ™¤T¨$£ZÓ0ˆØ× Ò Ü�H‰HØñ
ð ð
ð ×,Ñ,ØØ—;‘;ó
ð 	
r0   )rÖ   rø   rö   rÉ   rF   rp   r	  r  )r2   r3   r4   r5   r6   r7   r  r8   r   r  r   r  r  r   r   r�   rN   r   r9   r­   r:   rP   rL   r   rš   r.   r;   rY   rZ   s   @r-   r  r    s9  ø† ñ%ðN $×0Ñ0Ðð
 04Ø+/Ø>BØ7H×7PÑ7PØDEØ(,ñ%à�w—~‘~ xÐ/Ñ0ð%ð ˜H U™OÑ,ð%ð ˜ ™Ñ(ð	%ð
 ˜˜c 5¨(°5©/Ð9Ñ:Ñ;ð%ð Ð.°Ð3Ñ4ð%ð �I˜t E¨$°¨)Ñ$4°iÐ$?Ñ@Ð@ÑAð%ð ˜˜e™Ñ%ð%ð 
÷%ð %ðNP t¨C¡yð P°T¸#¸s¸(±^ô Pð6	
˜cð 	
¨4°°S°©>ð 	
¸c÷ 	
ò 	
r0   r  c                   ó  ^ • \ rS rSrSr\R                  rS\\	\
4   4U 4S jjr    SS\\\\   4   S\\\\\   4      S\S	\\\\\\	4   \4   4   S
\S   SS4U 4S jjjrS\\
   S\\	\
4   4S jrS\
S\\	\
4   S\
4S jrSrU =r$ )Ú
RandomCropi÷  aT
  Crop the input at a random location.

If the input is a :class:`torch.Tensor` or a ``TVTensor`` (e.g. :class:`~torchvision.tv_tensors.Image`,
:class:`~torchvision.tv_tensors.Video`, :class:`~torchvision.tv_tensors.BoundingBoxes` etc.)
it can have arbitrary number of leading batch dimensions. For example,
the image can have ``[..., C, H, W]`` shape. A bounding box can have ``[..., 4]`` shape.

Args:
    size (sequence or int): Desired output size of the crop. If size is an
        int instead of sequence like (h, w), a square crop (size, size) is
        made. If provided a sequence of length 1, it will be interpreted as (size[0], size[0]).
    padding (int or sequence, optional): Optional padding on each border
        of the image, applied before cropping. Default is None. If a single int is provided this
        is used to pad all borders. If sequence of length 2 is provided this is the padding
        on left/right and top/bottom respectively. If a sequence of length 4 is provided
        this is the padding for the left, top, right and bottom borders respectively.

        .. note::
            In torchscript mode padding as single int is not supported, use a sequence of
            length 1: ``[padding, ]``.
    pad_if_needed (boolean, optional): It will pad the image if smaller than the
        desired size to avoid raising an exception. Since cropping is done
        after padding, the padding seems to be done at a random offset.
    fill (number or tuple or dict, optional): Pixel fill value used when the  ``padding_mode`` is constant.
        Default is 0. If a tuple of length 3, it is used to fill R, G, B channels respectively.
        Fill value can be also a dictionary mapping data type to the fill value, e.g.
        ``fill={tv_tensors.Image: 127, tv_tensors.Mask: 0}`` where ``Image`` will be filled with 127 and
        ``Mask`` will be filled with 0.
    padding_mode (str, optional): Type of padding. Should be: constant, edge, reflect or symmetric.
        Default is constant.

        - constant: pads with a constant value, this value is specified with fill

        - edge: pads with the last value at the edge of the image.

        - reflect: pads with reflection of image without repeating the last value on the edge.
          For example, padding [1, 2, 3, 4] with 2 elements on both sides in reflect mode
          will result in [3, 2, 1, 2, 3, 4, 3, 2]

        - symmetric: pads with reflection of image repeating the last value on the edge.
          For example, padding [1, 2, 3, 4] with 2 elements on both sides in symmetric mode
          will result in [2, 1, 1, 2, 3, 4, 4, 3]
r%   c                 ó   >• [         TU ]  5       nUS   bL  [        US   [        [        45      (       d.  [        [        U 5      R                   SU R                   S35      eU R                  nUb	  Uu  p4pVX5XF/nX!S'   U$ )NrÉ   rÊ   rË   rÎ   )
rK   rÌ   rM   rN   r�   rQ   r­   r2   rÉ   rÎ   )r,   r$   rÎ   Úpad_leftÚ	pad_rightÚpad_topÚ
pad_bottomrR   s          €r-   rÌ   Ú+RandomCrop._extract_params_for_v1_transform&  s‹   ø€ Ü‘Ñ9Ó;ˆà�v‘Ñ&¬*°V¸F±^ÄcÌ5À\×*RÑ*RÜ¤ T£
× 3Ñ 3Ð4Ð4iÐjn×jsÑjsÐitÐtuÐvÓwÐwà—,‘,ˆØÑØ7>Ñ4ˆH Ø¨)Ð@ˆGØ#ˆyÑàˆr0   NrE   rÎ   Úpad_if_neededrÉ   rÏ   rÐ   c                 ó$  >• [         TU ]  5         [        USS9U l        U(       d  Ub  Ub  [	        U5        [        U5        U(       a  [        R                  R                  U5      OS U l	        X0l
        X@l        [        U5      U l        XPl        g r_   )rK   rL   r   rE   r   r   r)   Ú	_geometryÚ_parse_pad_paddingrÎ   r$  rÉ   r   rÖ   rÏ   )r,   rE   rÎ   r$  rÉ   rÏ   rR   s         €r-   rL   ÚRandomCrop.__init__4  st   ø€ ô 	‰ÑÔä Ð0eÑfˆŒ	æ˜GÑ/ØÑ"Ü" 7Ô+Ü# LÔ1æBI”q—{‘{×5Ñ5°gÔ>ÈtˆŒØ*ÔØŒ	Ü$ TÓ*ˆŒ
Ø(Õr0   r{   c           
      óŽ  • [        U5      u  p#U R                  b  U R                  u  pEpgX&U-   -  nX4U-   -  nOS=n=n=pgU R                  u  p‰U R                  (       a2  X(:  a  X‚-
  n
Xj-  nXz-  nUSU
-  -  nX9:  a  X“-
  n
XJ-  nXZ-  nUSU
-  -  nX(:  d  X9:  a&  [	        SX‰4 SU R                  b  SOS SX#4 S35      eXFXW/n[        U5      nX(:”  a&  S	[        [        R                  " SX(-
  S
-   SS95      4OSu  pÞX9:”  a&  S	[        [        R                  " SX9-
  S
-   SS95      4OSu  nn[        U=(       d    UUUUU	UUS9$ )Nr   rJ   zRequired crop size z is larger than zpadded Ú zinput image size rË   Tr   r1   rk   )Fr   )Ú
needs_cropr€   r�   r‚   rƒ   Ú	needs_padrÎ   )
r   rÎ   rE   r$  rQ   ÚanyrN   rv   rŒ   r9   )r,   r{   Úpadded_heightÚpadded_widthr  r   r!  r"  Úcropped_heightÚcropped_widthÚdiffrÎ   r,  Úneeds_vert_cropr€   Úneeds_horz_cropr�   s                    r-   rš   ÚRandomCrop.make_paramsK  s¸  € Ü&0°Ó&=Ñ#ˆà�<‰<Ñ#Ø7;·|±|Ñ4ˆH Ø zÑ1Ñ1ˆMØ yÑ0Ñ0‰Là:;Ð;ˆHÐ;�yÐ; 7à(,¯	©	Ñ%ˆà××ØÓ-Ø%Ñ5�à‘�ØÑ"�
Ø  T¡Ñ)�àÓ+Ø$Ñ3�àÑ �ØÑ!�	Ø  D¡Ñ(�àÓ)¨\Ó-IÜØ% ~Ð&EÐ%FÐFVØ $§¡Ñ 8‘9¸bÐAÐARÐTaÐSpÐRqÐqrðtóð ð  iÐ<ˆÜ˜“Lˆ	ð Ó-ð ”3”u—}’} Q¨Ñ(FÈÑ(JÐQSÑTÓUÑVàñ 	ˆð Ó+ð ”3”u—}’} Q¨Ñ(DÀqÑ(HÈrÑRÓSÑTàñ 	ˆ˜ô Ø&×9¨/ØØØ!ØØØñ
ð 	
r0   r#   r$   c           	      ó  • US   (       aK  [        U R                  [        U5      5      nU R                  [        R
                  XS   X0R                  S9nUS   (       a-  U R                  [        R                  XS   US   US   US   S	9nU$ )
Nr,  rÎ   rÙ   r+  r€   r�   r‚   rƒ   r   )r   rÖ   r­   r(   r)   rÚ   rÏ   ÚcroprÛ   s       r-   r.   ÚRandomCrop.transform…  s�   € Ø�+×Ü˜TŸZ™Z¬¨d«Ó4ˆDØ×$Ñ$¤Q§U¡U¨DÀÑ:KÐRV×evÑevÐ$ÐwˆDà�,×Ø×$Ñ$Ü—‘˜¨¡-°f¸V±nÈVÐT\ÑM]ÐekÐlsÑetð %ð ˆDð ˆr0   )rÖ   rÉ   r$  rÎ   rÏ   rE   )NFr   rÑ   )r2   r3   r4   r5   r6   r7   r  r8   r9   r:   r   rÌ   r   rN   r   r   rX   r   r­   r   rL   rP   rš   r.   r;   rY   rZ   s   @r-   r  r  ÷  s  ø† ñ*ðX $×.Ñ.Ðð°$°s¸C°x±.÷ ð" 8<Ø#ØDEØLVñ)à�C˜ #™Ð&Ñ'ð)ð ˜%  X¨c¡]Ð 2Ñ3Ñ4ð)ð ð	)ð
 �I˜t E¨$°¨)Ñ$4°iÐ$?Ñ@Ð@ÑAð)ð ÐHÑIð)ð 
÷)ð )ð.8
 t¨C¡yð 8
°T¸#¸s¸(±^ô 8
ðt
˜cð 
¨4°°S°©>ð 
¸c÷ 
ò 
r0   r  c                   óæ   ^ • \ rS rSrSr\R                  rSS\R                  S4S\
S\
S\\\4   S\\\\\\4   \4   4   S	S
4
U 4S jjjrS\\   S	\\\4   4S jrS\S\\\4   S	\4S jrSrU =r$ )ÚRandomPerspectivei’  aÞ  Perform a random perspective transformation of the input with a given probability.

If the input is a :class:`torch.Tensor` or a ``TVTensor`` (e.g. :class:`~torchvision.tv_tensors.Image`,
:class:`~torchvision.tv_tensors.Video`, :class:`~torchvision.tv_tensors.BoundingBoxes` etc.)
it can have arbitrary number of leading batch dimensions. For example,
the image can have ``[..., C, H, W]`` shape. A bounding box can have ``[..., 4]`` shape.

Args:
    distortion_scale (float, optional): argument to control the degree of distortion and ranges from 0 to 1.
        Default is 0.5.
    p (float, optional): probability of the input being transformed. Default is 0.5.
    interpolation (InterpolationMode, optional): Desired interpolation enum defined by
        :class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.BILINEAR``.
        If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported.
        The corresponding Pillow integer constants, e.g. ``PIL.Image.BILINEAR`` are accepted as well.
    fill (number or tuple or dict, optional): Pixel fill value used when the  ``padding_mode`` is constant.
        Default is 0. If a tuple of length 3, it is used to fill R, G, B channels respectively.
        Fill value can be also a dictionary mapping data type to the fill value, e.g.
        ``fill={tv_tensors.Image: 127, tv_tensors.Mask: 0}`` where ``Image`` will be filled with 127 and
        ``Mask`` will be filled with 0.
ró   r   Údistortion_scalerà   rF   rÉ   r%   Nc                 ó˜   >• [         TU ]  US9  SUs=::  a  S::  d  O  [        S5      eXl        X0l        X@l        [        U5      U l        g )Nrâ   r   r   z9Argument distortion_scale value should be between 0 and 1)rK   rL   rQ   r;  rF   rÉ   r   rÖ   )r,   r;  rà   rF   rÉ   rR   s        €r-   rL   ÚRandomPerspective.__init__«  sL   ø€ ô 	‰Ñ˜1ÐÑàÐ%Õ*¨Õ*ÜÐXÓYÐYà 0ÔØ*ÔØŒ	Ü$ TÓ*ˆ�
r0   r{   c           	      óì  • [        U5      u  p#U R                  nUS-  nUS-  n[        XE-  5      S-   n[        XF-  5      S-   n[        [        R                  " SUSS95      [        [        R                  " SUSS95      /n	[        [        R                  " X8-
  USS95      [        [        R                  " SUSS95      /n
[        [        R                  " X8-
  USS95      [        [        R                  " X'-
  USS95      /n[        [        R                  " SUSS95      [        [        R                  " X'-
  USS95      /nSS/US-
  S/US-
  US-
  /SUS-
  //nXšX¼/n[        XÞ5      n[        US9$ )NrJ   r   r   r~   rk   )Úcoefficients)r   r;  rN   rv   rŒ   r   r9   )r,   r{   r‚   rƒ   r;  Úhalf_heightÚ
half_widthÚbound_heightÚbound_widthÚtopleftÚtoprightÚbotrightÚbotleftÚstartpointsÚ	endpointsÚperspective_coeffss                   r-   rš   ÚRandomPerspective.make_params¼  s{  € Ü" ;Ó/‰ˆà×0Ñ0Ðà ‘kˆØ˜a‘Zˆ
ÜÐ+Ñ9Ó:¸QÑ>ˆÜÐ*Ñ7Ó8¸1Ñ<ˆä”—’˜a °4Ñ8Ó9Ü”—’˜a °DÑ9Ó:ð
ˆô
 ”—’˜eÑ1°5¸tÑDÓEÜ”—’˜a °DÑ9Ó:ð
ˆô
 ”—’˜eÑ1°5¸tÑDÓEÜ”—’˜fÑ3°VÀ$ÑGÓHð
ˆô
 ”—’˜a °4Ñ8Ó9Ü”—’˜fÑ3°VÀ$ÑGÓHð
ˆð ˜1�v ¨¡	¨1˜~°¸±	¸6ÀA¹:Ð/FÈÈFÐUVÉJÈÐXˆØ¨Ð:ˆ	Ü4°[ÓLÐÜÐ!3Ñ4Ð4r0   r#   r$   c                 ó¢   • [        U R                  [        U5      5      nU R                  " [        R
                  U4S S UU R                  S.UD6$ )N)rH  rI  rÉ   rF   )r   rÖ   r­   r(   r)   ÚperspectiverF   rÛ   s       r-   r.   ÚRandomPerspective.transformÚ  sV   € Ü˜Ÿ™¤T¨$£ZÓ0ˆØ× Ò Ü�M‰MØð
ð ØØØ×,Ñ,ñ
ð ñ
ð 	
r0   )rÖ   r;  rÉ   rF   )r2   r3   r4   r5   r6   r7   r:  r8   r   rW   r�   r   rN   r   r9   r­   r:   rL   rP   r   rš   r.   r;   rY   rZ   s   @r-   r:  r:  ’  sÒ   ø† ñð, $×5Ñ5Ðð #&ØØ7H×7QÑ7QØDEñ+àð+ð ð+ð Ð.°Ð3Ñ4ð	+ð
 �I˜t E¨$°¨)Ñ$4°iÐ$?Ñ@Ð@ÑAð+ð 
÷+ð +ð"5 t¨C¡yð 5°T¸#¸s¸(±^ô 5ð<

˜cð 

¨4°°S°©>ð 

¸c÷ 

ò 

r0   r:  c                   ó  ^ • \ rS rSrSr\R                  rSS\R                  S4S\
\\\   4   S\
\\\   4   S\
\\4   S	\
\\\
\\4   \4   4   S
S4
U 4S jjjrS\\   S
\\\4   4S jrS\S\\\4   S
\4S jrSrU =r$ )ÚElasticTransformiç  ak	  Transform the input with elastic transformations.

If the input is a :class:`torch.Tensor` or a ``TVTensor`` (e.g. :class:`~torchvision.tv_tensors.Image`,
:class:`~torchvision.tv_tensors.Video`, :class:`~torchvision.tv_tensors.BoundingBoxes` etc.)
it can have arbitrary number of leading batch dimensions. For example,
the image can have ``[..., C, H, W]`` shape. A bounding box can have ``[..., 4]`` shape.

Given alpha and sigma, it will generate displacement
vectors for all pixels based on random offsets. Alpha controls the strength
and sigma controls the smoothness of the displacements.
The displacements are added to an identity grid and the resulting grid is
used to transform the input.

.. note::
    Implementation to transform bounding boxes is approximative (not exact).
    We construct an approximation of the inverse grid as ``inverse_grid = identity - displacement``.
    This is not an exact inverse of the grid used to transform images, i.e. ``grid = identity + displacement``.
    Our assumption is that ``displacement * displacement`` is small and can be ignored.
    Large displacements would lead to large errors in the approximation.

Applications:
    Randomly transforms the morphology of objects in images and produces a
    see-through-water-like effect.

Args:
    alpha (float or sequence of floats, optional): Magnitude of displacements.
        Default is 50.0. A single value is ``[alpha, alpha]``.
    sigma (float or sequence of floats, optional): Smoothness of displacements.
        Default is 5.0. A single value is ``[sigma, sigma]``.
    interpolation (InterpolationMode, optional): Desired interpolation enum defined by
        :class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.BILINEAR``.
        If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported.
        The corresponding Pillow integer constants, e.g. ``PIL.Image.BILINEAR`` are accepted as well.
    fill (number or tuple or dict, optional): Pixel fill value used when the  ``padding_mode`` is constant.
        Default is 0. If a tuple of length 3, it is used to fill R, G, B channels respectively.
        Fill value can be also a dictionary mapping data type to the fill value, e.g.
        ``fill={tv_tensors.Image: 127, tv_tensors.Mask: 0}`` where ``Image`` will be filled with 127 and
        ``Mask`` will be filled with 0.
g      I@g      @r   ÚalphaÚsigmarF   rÉ   r%   Nc                 óž   >• [         TU ]  5         [        US5      U l        [        US5      U l        X0l        X@l        [        U5      U l        g )NrQ  rR  )	rK   rL   r   rQ  rR  rF   rÉ   r   rÖ   )r,   rQ  rR  rF   rÉ   rR   s        €r-   rL   ÚElasticTransform.__init__  sC   ø€ ô 	‰ÑÔÜ)¨%°Ó9ˆŒ
Ü)¨%°Ó9ˆŒ
à*ÔØŒ	Ü$ TÓ*ˆ�
r0   r{   c                 ó  • [        U5      u  p#[        R                  " SSX#5      S-  S-
  nU R                  S   S:”  ab  [	        SU R                  S   -  S-   5      nUS-  S:X  a  US-  nU R                  [        R                  XEU/[        U R                  5      5      nX@R                  S   -  U-  n[        R                  " SSX#5      S-  S-
  nU R                  S   S:”  ab  [	        SU R                  S   -  S-   5      nUS-  S:X  a  US-  nU R                  [        R                  XgU/[        U R                  5      5      nX`R                  S   -  U-  n[        R                  " XF/S5      R                  / SQ5      n[        US9$ )Nr   rJ   r   r  é   )r   rJ   r  r   )Údisplacement)r   rv   rè   rR  rN   r(   r)   Úgaussian_blurrP   rQ  ÚconcatÚpermuter9   )	r,   r{   r‚   rƒ   ÚdxÚkxÚdyÚkyrW  s	            r-   rš   ÚElasticTransform.make_params!  sb  € Ü" ;Ó/‰ˆä�ZŠZ˜˜1˜fÓ,¨qÑ0°1Ñ4ˆØ�:‰:�a‰=˜3ÓÜ�Q˜Ÿ™ A™Ñ&¨Ñ*Ó+ˆBà�A‰v˜‹{Ø�a‘�Ø×"Ñ"¤1§?¡?°B¸R¸Ä$ÀtÇzÁzÓBRÓSˆBØ—*‘*˜Q‘-Ñ %Ñ'ˆä�ZŠZ˜˜1˜fÓ,¨qÑ0°1Ñ4ˆØ�:‰:�a‰=˜3ÓÜ�Q˜Ÿ™ A™Ñ&¨Ñ*Ó+ˆBà�A‰v˜‹{Ø�a‘�Ø×"Ñ"¤1§?¡?°B¸R¸Ä$ÀtÇzÁzÓBRÓSˆBØ—*‘*˜Q‘-Ñ &Ñ(ˆÜ—|’| R H¨aÓ0×8Ñ8ºÓFˆÜ Ñ.Ð.r0   r#   r$   c                 ó¢   • [        U R                  [        U5      5      nU R                  " [        R
                  U40 UDUU R                  S.D6$ )N)rÉ   rF   )r   rÖ   r­   r(   r)   ÚelasticrF   rÛ   s       r-   r.   ÚElasticTransform.transform8  sP   € Ü˜Ÿ™¤T¨$£ZÓ0ˆØ× Ò Ü�I‰IØñ
ð ð
ð Ø×,Ñ,ó
ð 	
r0   )rÖ   rQ  rÉ   rF   rR  )r2   r3   r4   r5   r6   r7   rP  r8   r   rW   r   r�   r   rN   r   r9   r­   r:   rL   rP   r   rš   r.   r;   rY   rZ   s   @r-   rP  rP  ç  sï   ø† ñ&ðP $×4Ñ4Ðð 04Ø/2Ø7H×7QÑ7QØDEñ+à�U˜H U™OÐ+Ñ,ð+ð �U˜H U™OÐ+Ñ,ð+ð Ð.°Ð3Ñ4ð	+ð
 �I˜t E¨$°¨)Ñ$4°iÐ$?Ñ@Ð@ÑAð+ð 
÷+ð +ð/ t¨C¡yð /°T¸#¸s¸(±^ô /ð.
˜cð 
¨4°°S°©>ð 
¸c÷ 
ò 
r0   rP  c                   ó¾   ^ • \ rS rSrSr      SS\S\S\S\S\\\      S	\4U 4S
 jjjr	S\\
   SS4S jrS\\
   S\\\
4   4S jrS\
S\\\
4   S\
4S jrSrU =r$ )ÚRandomIoUCropiC  aó  Random IoU crop transformation from
`"SSD: Single Shot MultiBox Detector" <https://arxiv.org/abs/1512.02325>`_.

This transformation requires an image or video data and ``tv_tensors.BoundingBoxes`` in the input.

.. warning::
    In order to properly remove the bounding boxes below the IoU threshold, `RandomIoUCrop`
    must be followed by :class:`~torchvision.transforms.v2.SanitizeBoundingBoxes`, either immediately
    after or later in the transforms pipeline.

If the input is a :class:`torch.Tensor` or a ``TVTensor`` (e.g. :class:`~torchvision.tv_tensors.Image`,
:class:`~torchvision.tv_tensors.Video`, :class:`~torchvision.tv_tensors.BoundingBoxes` etc.)
it can have arbitrary number of leading batch dimensions. For example,
the image can have ``[..., C, H, W]`` shape. A bounding box can have ``[..., 4]`` shape.

Args:
    min_scale (float, optional): Minimum factors to scale the input size.
    max_scale (float, optional): Maximum factors to scale the input size.
    min_aspect_ratio (float, optional): Minimum aspect ratio for the cropped image or video.
    max_aspect_ratio (float, optional): Maximum aspect ratio for the cropped image or video.
    sampler_options (list of float, optional): List of minimal IoU (Jaccard) overlap between all the boxes and
        a cropped image or video. Default, ``None`` which corresponds to ``[0.0, 0.1, 0.3, 0.5, 0.7, 0.9, 1.0]``
    trials (int, optional): Number of trials to find a crop for a given value of minimal IoU (Jaccard) overlap.
        Default, 40.
NÚ	min_scaleÚ	max_scaleÚmin_aspect_ratioÚmax_aspect_ratioÚsampler_optionsÚtrialsc                 óx   >• [         TU ]  5         Xl        X l        X0l        X@l        Uc  / SQnXPl        X`l        g )N)r  çš™™™™™¹?ç333333Ó?ró   gffffffæ?gÍÌÌÌÌÌì?ro   )rK   rL   re  rf  rg  rh  Úoptionsrj  )r,   re  rf  rg  rh  ri  rj  rR   s          €r-   rL   ÚRandomIoUCrop.__init__^  s;   ø€ ô 	‰ÑÔà"ŒØ"ŒØ 0ÔØ 0ÔØÑ"ÚAˆOØ&ŒØ�r0   r{   r%   c                 óþ   • [        U[        R                  5      (       a=  [        U[        R
                  R
                  [        R
                  [        5      (       d!  [        [        U 5      R                   S35      eg )Nzk() requires input sample to contain tensor or PIL images and bounding boxes. Sample can also contain masks.)
r   r
   rª   r   ÚPILÚImager   rs   r­   r2   r·   s     r-   r¸   ÚRandomIoUCrop.check_inputsr  sc   € ä�K¤×!9Ñ!9×:Ñ:Ü˜¤S§Y¡Y§_¡_´j×6FÑ6FÌ×WÑWäÜ˜“:×&Ñ&Ð'ð (Eð Eóð ð Xr0   c           
      óÂ  • [        U5      u  p#[        U5      n [        [        R                  " S[        U R                  5      SS95      nU R                  U   nUS:¼  a
  [        5       $ [        U R                  5       GHÙ  nU R                  U R                  U R                  -
  [        R                  " S5      -  -   n[        X8S   -  5      n	[        X(S   -  5      n
Xš-  nU R                  Us=::  a  U R                  ::  d  O  MŠ  [        R                  " S5      n[        X9-
  US   -  5      n[        X*-
  US   -  5      nXÉ-   nXÚ-   nXÎ:X  d  Xß:X  a  MÚ  [        R                   " UR#                  [        R$                  5      UR&                  [(        R*                  R,                  5      nSUS   US	   -   -  nSUS
   US   -   -  nUU:  UU:  -  UU:  -  UU:  -  nUR/                  5       (       d  GM|  UU   n[1        U[        R2                  " XÍXï//UR4                  UR6                  S95      nUR9                  5       U:  a  GMÏ  [        XÜX©US9s  $    GMG  )Nr   r~   )ÚlowÚhighrE   ro   rJ   r   ró   ).r   ).rJ   ).r   ).r  )ÚdtypeÚdevice)r€   r�   r‚   rƒ   Úis_within_crop_area)r   r   rN   rv   rŒ   rO   rn  r9   r„   rj  re  rf  rè   rg  rh  r)   Úconvert_bounding_box_formatÚas_subclassÚTensorÚformatr
   ÚBoundingBoxFormatÚXYXYr-  r   rx   rw  rx  r�   )r,   r{   ré   rê   ÚbboxesÚidxÚmin_jaccard_overlapr’   rë   Únew_wÚnew_hr”   r�   r€   rî   rï   Úxyxy_bboxesÚcxÚcyry  Úiouss                        r-   rš   ÚRandomIoUCrop.make_params|  s<  € Ü# KÓ0‰ˆÜ# KÓ0ˆàä”e—m’m¨´°D·L±LÓ0AÈÑMÓNˆCØ"&§,¡,¨sÑ"3ÐØ" cÓ)Ü“v�ä˜4Ÿ;™;×'�à—N‘N d§n¡n°t·~±~Ñ&EÌÏÊÐTUËÑ%VÑV�Ü˜F q¡T™MÓ*�Ü˜F q¡T™MÓ*�Ø$™}�Ø×-Ñ-°ÕVÀ×AVÑAVÕVÙô —J’J˜q“M�Ü˜F™N¨a°©dÑ2Ó3�Ü˜6™>¨Q¨q©TÑ1Ó2�Ø™�Ø™�Ø“= C£MÙô  ×;Ò;Ø×&Ñ&¤u§|¡|Ó4Ø—M‘MÜ×0Ñ0×5Ñ5ó�ð
 ˜K¨Ñ/°+¸fÑ2EÑEÑF�Ø˜K¨Ñ/°+¸fÑ2EÑEÑF�Ø'+¨b¡y°R¸%±ZÑ&@ÀCÈ"ÁHÑ&MÐQSÐV\ÑQ\Ñ&]Ð#Ø*×.Ñ.×0Ñ0Úð *Ð*=Ñ>�ÜØÜ—L’L 4¨eÐ"<Ð!=À[×EVÑEVÐ_j×_qÑ_qÑró�ð —8‘8“:Ð 3Ó3Úä °uÐ_rÑsÒsñO (ò r0   r#   r$   c           	      óÐ   • [        U5      S:  a  U$ U R                  [        R                  XS   US   US   US   S9n[	        U[
        R                  5      (       a  SX2S   ) '   U$ )	Nr   r€   r�   r‚   rƒ   r   r   ry  )rO   r(   r)   r7  rM   r
   rª   )r,   r#   r$   Úoutputs       r-   r.   ÚRandomIoUCrop.transform°  sx   € äˆv‹;˜‹?ØˆKà×"Ñ"Ü�F‰F�D U™m°&¸±.ÈÐPXÑIYÐagÐhoÑapð #ð 
ˆô �fœj×6Ñ6×7Ñ7ð 67ˆFÐ0Ñ1Ð1Ñ2àˆr0   )rh  rf  rg  re  rn  rj  )rm  ro   ró   ç       @Né(   )r2   r3   r4   r5   r6   r�   r   rP   rN   rL   r   r¸   r9   r:   rš   r.   r;   rY   rZ   s   @r-   rd  rd  C  sÊ   ø† ñð8 ØØ"%Ø"%Ø15Øñàðð ðð  ð	ð
  ðð " $ u¡+Ñ.ðð ÷ð ð(¨¨S©	ð °dô ð2t t¨C¡yð 2t°T¸#¸s¸(±^ô 2tðh˜cð ¨4°°S°©>ð ¸c÷ ò r0   rd  c            
       óÄ   ^ • \ rS rSrSrS\R                  S4S\\\4   S\\	\	4   S\
\\4   S\\   4U 4S	 jjjrS
\\   S\\\4   4S jrS\S\\\4   S\4S jrSrU =r$ )ÚScaleJitteriÁ  a`	  Perform Large Scale Jitter on the input according to
`"Simple Copy-Paste is a Strong Data Augmentation Method for Instance Segmentation" <https://arxiv.org/abs/2012.07177>`_.

If the input is a :class:`torch.Tensor` or a ``TVTensor`` (e.g. :class:`~torchvision.tv_tensors.Image`,
:class:`~torchvision.tv_tensors.Video`, :class:`~torchvision.tv_tensors.BoundingBoxes` etc.)
it can have arbitrary number of leading batch dimensions. For example,
the image can have ``[..., C, H, W]`` shape. A bounding box can have ``[..., 4]`` shape.

Args:
    target_size (tuple of int): Target size. This parameter defines base scale for jittering,
        e.g. ``min(target_size[0] / width, target_size[1] / height)``.
    scale_range (tuple of float, optional): Minimum and maximum of the scale range. Default, ``(0.1, 2.0)``.
    interpolation (InterpolationMode, optional): Desired interpolation enum defined by
        :class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.BILINEAR``.
        If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.NEAREST_EXACT``,
        ``InterpolationMode.BILINEAR`` and ``InterpolationMode.BICUBIC`` are supported.
        The corresponding Pillow integer constants, e.g. ``PIL.Image.BILINEAR`` are accepted as well.
    antialias (bool, optional): Whether to apply antialiasing.
        It only affects **tensors** with bilinear or bicubic modes and it is
        ignored otherwise: on PIL images, antialiasing is always applied on
        bilinear or bicubic modes; on other modes (for PIL images and
        tensors), antialiasing makes no sense and this parameter is ignored.
        Possible values are:

        - ``True`` (default): will apply antialiasing for bilinear or bicubic modes.
          Other mode aren't affected. This is probably what you want to use.
        - ``False``: will not apply antialiasing for tensors on any mode. PIL
          images are still antialiased on bilinear or bicubic modes, because
          PIL doesn't support no antialias.
        - ``None``: equivalent to ``False`` for tensors and ``True`` for
          PIL images. This value exists for legacy reasons and you probably
          don't want to use it unless you really know what you are doing.

        The default value changed from ``None`` to ``True`` in
        v0.17, for the PIL and Tensor backends to be consistent.
)rl  r�  TÚtarget_sizeÚscale_rangerF   rH   c                 óR   >• [         TU ]  5         Xl        X l        X0l        X@l        g r'   )rK   rL   r‘  r’  rF   rH   )r,   r‘  r’  rF   rH   rR   s        €r-   rL   ÚScaleJitter.__init__ç  s'   ø€ ô 	‰ÑÔØ&ÔØ&ÔØ*ÔØ"�r0   r{   r%   c                 óN  • [        U5      u  p#U R                  S   [        R                  " S5      U R                  S   U R                  S   -
  -  -   n[	        U R
                  S   U-  U R
                  S   U-  5      U-  n[        X5-  5      n[        X%-  5      n[        Xv4S9$ )Nr   r   rk   )r   r’  rv   rè   rŽ   r‘  rN   r9   )r,   r{   Úorig_heightÚ
orig_widthrp   rë   Ú	new_widthÚ
new_heights           r-   rš   ÚScaleJitter.make_paramsô  s¥   € Ü",¨[Ó"9Ñˆà× Ñ  Ñ#¤e§j¢j°£m°t×7GÑ7GÈÑ7JÈT×M]ÑM]Ð^_ÑM`Ñ7`Ñ&aÑaˆÜ�× Ñ  Ñ# kÑ1°4×3CÑ3CÀAÑ3FÈÑ3SÓTÐW\Ñ\ˆÜ˜
™Ó'ˆ	Ü˜™Ó)ˆ
ä˜*Ð0Ñ1Ð1r0   r#   r$   c                 óp   • U R                  [        R                  XS   U R                  U R                  S9$ ©NrE   r�   ©r(   r)   rU   rF   rH   r+   s      r-   r.   ÚScaleJitter.transformþ  ó8   € Ø× Ñ Ü�H‰H�d¨¡¸t×?QÑ?QÐ]a×]kÑ]kð !ð 
ð 	
r0   )rH   rF   r’  r‘  )r2   r3   r4   r5   r6   r   rW   r    rN   r�   r   r   rX   rL   rP   r   r9   r:   rš   r.   r;   rY   rZ   s   @r-   r�  r�  Á  s°   ø† ñ#ðP ,6Ø7H×7QÑ7QØ$(ñ#à˜3 ˜8‘_ð#ð ˜5 %˜<Ñ(ð#ð Ð.°Ð3Ñ4ð	#ð
 ˜D‘>÷#ð #ð2 t¨C¡yð 2°T¸#¸s¸(±^ô 2ð
˜cð 
¨4°°S°©>ð 
¸c÷ 
ò 
r0   r�  c            
       óÎ   ^ • \ rS rSrSrS\R                  S4S\\\	   \
\	   \	4   S\\	   S\\\	4   S\\   4U 4S	 jjjrS
\\   S\\\4   4S jrS\S\\\4   S\4S jrSrU =r$ )ÚRandomShortestSizei  ap  Randomly resize the input.

If the input is a :class:`torch.Tensor` or a ``TVTensor`` (e.g. :class:`~torchvision.tv_tensors.Image`,
:class:`~torchvision.tv_tensors.Video`, :class:`~torchvision.tv_tensors.BoundingBoxes` etc.)
it can have arbitrary number of leading batch dimensions. For example,
the image can have ``[..., C, H, W]`` shape. A bounding box can have ``[..., 4]`` shape.

Args:
    min_size (int or sequence of int): Minimum spatial size. Single integer value or a sequence of integer values.
    max_size (int, optional): Maximum spatial size. Default, None.
    interpolation (InterpolationMode, optional): Desired interpolation enum defined by
        :class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.BILINEAR``.
        If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.NEAREST_EXACT``,
        ``InterpolationMode.BILINEAR`` and ``InterpolationMode.BICUBIC`` are supported.
        The corresponding Pillow integer constants, e.g. ``PIL.Image.BILINEAR`` are accepted as well.
    antialias (bool, optional): Whether to apply antialiasing.
        It only affects **tensors** with bilinear or bicubic modes and it is
        ignored otherwise: on PIL images, antialiasing is always applied on
        bilinear or bicubic modes; on other modes (for PIL images and
        tensors), antialiasing makes no sense and this parameter is ignored.
        Possible values are:

        - ``True`` (default): will apply antialiasing for bilinear or bicubic modes.
          Other mode aren't affected. This is probably what you want to use.
        - ``False``: will not apply antialiasing for tensors on any mode. PIL
          images are still antialiased on bilinear or bicubic modes, because
          PIL doesn't support no antialias.
        - ``None``: equivalent to ``False`` for tensors and ``True`` for
          PIL images. This value exists for legacy reasons and you probably
          don't want to use it unless you really know what you are doing.

        The default value changed from ``None`` to ``True`` in
        v0.17, for the PIL and Tensor backends to be consistent.
NTÚmin_sizerG   rF   rH   c                 ó–   >• [         TU ]  5         [        U[        5      (       a  U/O
[	        U5      U l        X l        X0l        X@l        g r'   )	rK   rL   rM   rN   rP   r¢  rG   rF   rH   ©r,   r¢  rG   rF   rH   rR   s        €r-   rL   ÚRandomShortestSize.__init__(  s;   ø€ ô 	‰ÑÔÜ&0°¼3×&?Ñ&?˜™
ÄTÈ(Ã^ˆŒØ ŒØ*ÔØ"�r0   r{   r%   c                 ó\  • [        U5      u  p#U R                  [        [        R                  " [        U R                  5      S5      5         nU[        X#5      -  nU R                  b!  [        XPR                  [        X#5      -  5      n[        X5-  5      n[        X%-  5      n[        Xv4S9$ ©Nr1   rk   )
r   r¢  rN   rv   rŒ   rO   rŽ   rG   r�   r9   )r,   r{   r–  r—  r¢  rë   r˜  r™  s           r-   rš   ÚRandomShortestSize.make_params5  s�   € Ü",¨[Ó"9Ñˆà—=‘=¤¤U§]¢]´3°t·}±}Ó3EÀrÓ%JÓ!KÑLˆØ”s˜;Ó3Ñ3ˆØ�=‰=Ñ$Ü�A—}‘}¤s¨;Ó'CÑCÓDˆAä˜
™Ó'ˆ	Ü˜™Ó)ˆ
ä˜*Ð0Ñ1Ð1r0   r#   r$   c                 óp   • U R                  [        R                  XS   U R                  U R                  S9$ rœ  r�  r+   s      r-   r.   ÚRandomShortestSize.transformB  rŸ  r0   ©rH   rF   rG   r¢  )r2   r3   r4   r5   r6   r   rW   r   rP   rN   r    r   rX   rL   r   r9   r:   rš   r.   r;   rY   rZ   s   @r-   r¡  r¡    s·   ø† ñ!ðL #'Ø7H×7QÑ7QØ$(ñ#à˜˜S™	 5¨¡:¨sÐ2Ñ3ð#ð ˜3‘-ð#ð Ð.°Ð3Ñ4ð	#ð
 ˜D‘>÷#ð #ð2 t¨C¡yð 2°T¸#¸s¸(±^ô 2ð
˜cð 
¨4°°S°©>ð 
¸c÷ 
ò 
r0   r¡  c                   ó²   ^ • \ rS rSrSr\R                  S4S\S\S\\\4   S\	\
   SS	4
U 4S
 jjjrS\\   S\\\4   4S jrS\S\\\4   S\4S jrSrU =r$ )ÚRandomResizeiH  a	  Randomly resize the input.

This transformation can be used together with ``RandomCrop`` as data augmentations to train
models on image segmentation task.

Output spatial size is randomly sampled from the interval ``[min_size, max_size]``:

.. code-block:: python

    size = uniform_sample(min_size, max_size)
    output_width = size
    output_height = size

If the input is a :class:`torch.Tensor` or a ``TVTensor`` (e.g. :class:`~torchvision.tv_tensors.Image`,
:class:`~torchvision.tv_tensors.Video`, :class:`~torchvision.tv_tensors.BoundingBoxes` etc.)
it can have arbitrary number of leading batch dimensions. For example,
the image can have ``[..., C, H, W]`` shape. A bounding box can have ``[..., 4]`` shape.

Args:
    min_size (int): Minimum output size for random sampling
    max_size (int): Maximum output size for random sampling
    interpolation (InterpolationMode, optional): Desired interpolation enum defined by
        :class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.BILINEAR``.
        If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.NEAREST_EXACT``,
        ``InterpolationMode.BILINEAR`` and ``InterpolationMode.BICUBIC`` are supported.
        The corresponding Pillow integer constants, e.g. ``PIL.Image.BILINEAR`` are accepted as well.
    antialias (bool, optional): Whether to apply antialiasing.
        It only affects **tensors** with bilinear or bicubic modes and it is
        ignored otherwise: on PIL images, antialiasing is always applied on
        bilinear or bicubic modes; on other modes (for PIL images and
        tensors), antialiasing makes no sense and this parameter is ignored.
        Possible values are:

        - ``True`` (default): will apply antialiasing for bilinear or bicubic modes.
          Other mode aren't affected. This is probably what you want to use.
        - ``False``: will not apply antialiasing for tensors on any mode. PIL
          images are still antialiased on bilinear or bicubic modes, because
          PIL doesn't support no antialias.
        - ``None``: equivalent to ``False`` for tensors and ``True`` for
          PIL images. This value exists for legacy reasons and you probably
          don't want to use it unless you really know what you are doing.

        The default value changed from ``None`` to ``True`` in
        v0.17, for the PIL and Tensor backends to be consistent.
Tr¢  rG   rF   rH   r%   Nc                 óR   >• [         TU ]  5         Xl        X l        X0l        X@l        g r'   )rK   rL   r¢  rG   rF   rH   r¤  s        €r-   rL   ÚRandomResize.__init__w  s%   ø€ ô 	‰ÑÔØ ŒØ ŒØ*ÔØ"�r0   r{   c                 ó€   • [        [        R                  " U R                  U R                  S5      5      n[        U/S9$ r§  )rN   rv   rŒ   r¢  rG   r9   )r,   r{   rE   s      r-   rš   ÚRandomResize.make_params„  s.   € Ü”5—=’= §¡°·±¸rÓBÓCˆÜ˜$˜Ñ Ð r0   r#   r$   c                 óp   • U R                  [        R                  XS   U R                  U R                  S9$ )NrE   )rF   rH   r�  r+   s      r-   r.   ÚRandomResize.transformˆ  s8   € Ø× Ñ Ü�H‰H�d 6™N¸$×:LÑ:LÐX\×XfÑXfð !ð 
ð 	
r0   r«  )r2   r3   r4   r5   r6   r   rW   rN   r   r   rX   rL   rP   r   r9   r:   rš   r.   r;   rY   rZ   s   @r-   r­  r­  H  s§   ø† ñ,ðd 8I×7QÑ7QØ$(ñ#àð#ð ð#ð Ð.°Ð3Ñ4ð	#ð
 ˜D‘>ð#ð 
÷#ð #ð! t¨C¡yð !°T¸#¸s¸(±^ô !ð
˜cð 
¨4°°S°©>ð 
¸c÷ 
ò 
r0   r­  )?rŠ   r  rt   Úcollections.abcr   Útypingr   r   r   r   r   Ú	PIL.Imagerq  rv   Útorchvisionr	   r7   r
   Útorchvision.ops.boxesr   Ú!torchvision.transforms.functionalr   Útorchvision.transforms.v2r   r)   r   r   Ú+torchvision.transforms.v2.functional._utilsr   Ú
_transformr   Ú_utilsr   r   r   r   r   r   r   r   r   r   r   r   r   r!   r=   rC   r\   rm   r¢   r¼   rÇ   rÞ   rõ   r  r  r:  rP  rd  r�  r¡  r­  r1   r0   r-   Ú<module>r¾     sT  ðÛ Û Û Ý $ß :Õ :ã Û ç =Ý )Ý Eß SÑ SÝ Aå -÷÷ ÷ õ ô":Ð0ô :ô$8Ð.ô 8ô$b
ˆYô b
ôJM�ô Mô4t
˜	ô t
ôn8iˆyô 8iôv*`ˆiô *`ôZEoˆ)ô EoôPACÐ)ô ACôHL
�Yô L
ô^u
�9ô u
ôpX�ô XôvR
Ð-ô R
ôjY
�yô Y
ôx{�Iô {ô|@
�)ô @
ôFA
˜ô A
ôHC
�9õ C
r0   