
    QЦiSn                        S SK r S SKJr  S SKJrJrJrJr  S SKrS SKJ	r	  SSK
JrJr  / SQrS\	S	\S
\S\S\\\      4
S jr " S S\5      r " S S\R&                  R(                  5      r " S S\R&                  R(                  5      r " S S\R&                  R(                  5      r " S S\R&                  R(                  5      rg)    N)Enum)DictListOptionalTuple)Tensor   )
functionalInterpolationMode)AutoAugmentPolicyAutoAugmentRandAugmentTrivialAugmentWideAugMiximgop_name	magnitudeinterpolationfillc                    US:X  aK  [         R                  " U SSS/S[        R                  " [        R                  " U5      5      S/UUSS/S9n U $ US:X  aK  [         R                  " U SSS/SS[        R                  " [        R                  " U5      5      /UUSS/S9n U $ US:X  a)  [         R                  " U S[        U5      S/SUSS/US9n U $ US	:X  a)  [         R                  " U SS[        U5      /SUSS/US9n U $ US
:X  a  [         R                  " XX4S9n U $ US:X  a  [         R                  " U SU-   5      n U $ US:X  a  [         R                  " U SU-   5      n U $ US:X  a  [         R                  " U SU-   5      n U $ US:X  a  [         R                  " U SU-   5      n U $ US:X  a"  [         R                  " U [        U5      5      n U $ US:X  a  [         R                  " X5      n U $ US:X  a  [         R                  " U 5      n U $ US:X  a  [         R                  " U 5      n U $ US:X  a  [         R                  " U 5      n U $ US:X  a   U $ [!        SU S35      e)NShearX        r         ?)angle	translatescaleshearr   r   centerShearY
TranslateX)r   r   r   r   r   r   
TranslateYRotater   r   
BrightnessColorContrast	Sharpness	PosterizeSolarizeAutoContrastEqualizeInvertIdentityzThe provided operator  is not recognized.)Faffinemathdegreesatanintrotateadjust_brightnessadjust_saturationadjust_contrastadjust_sharpness	posterizesolarizeautocontrastequalizeinvert
ValueError)r   r   r   r   r   s        a/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/torchvision/transforms/autoaugment.py	_apply_oprA      s    ( hh!f<<		) 45s;'q6	
F Js 
H	 hh!fTYYy%9:;'q6	
l JY 
L	 hh9~q)'*
V JE 
L	 hh#i.)'*
B J1 
H	hhs]N. J- 
L	 !!#sY7* J) 
G	!!#sY7& J% 
J	S9_5" J! 
K	  cIo6 J 
K	kk#s9~. J 
J	jj( J 
N	"nnS! J 
J	jjo J 
H	hhsm
 J	 
J	 J 1':MNOO    c                   $    \ rS rSrSrSrSrSrSrg)r   ]   zgAutoAugment policies learned on different datasets.
Available policies are IMAGENET, CIFAR10 and SVHN.
imagenetcifar10svhn N)	__name__
__module____qualname____firstlineno____doc__IMAGENETCIFAR10SVHN__static_attributes__rH   rB   r@   r   r   ]   s     HGDrB   r   c                   @  ^  \ rS rSrSr\R                  \R                  S4S\S\S\	\
\      SS4U 4S jjjrS\S\
\\\\\	\   4   \\\\	\   4   4      4S	 jrS
\S\\\4   S\\\\\4   4   4S jr\S\S\\\\4   4S j5       rS\S\4S jrS\4S jrSrU =r$ )r   h   a  AutoAugment data augmentation method based on
`"AutoAugment: Learning Augmentation Strategies from Data" <https://arxiv.org/pdf/1805.09501.pdf>`_.
If the image is torch Tensor, it should be of type torch.uint8, and it is expected
to have [..., 1 or 3, H, W] shape, where ... means an arbitrary number of leading dimensions.
If img is PIL Image, it is expected to be in mode "L" or "RGB".

Args:
    policy (AutoAugmentPolicy): Desired policy enum defined by
        :class:`torchvision.transforms.autoaugment.AutoAugmentPolicy`. Default is ``AutoAugmentPolicy.IMAGENET``.
    interpolation (InterpolationMode): Desired interpolation enum defined by
        :class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.NEAREST``.
        If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported.
    fill (sequence or number, optional): Pixel fill value for the area outside the transformed
        image. If given a number, the value is used for all bands respectively.
Npolicyr   r   returnc                 r   > [         TU ]  5         Xl        X l        X0l        U R                  U5      U l        g N)super__init__rT   r   r   _get_policiespolicies)selfrT   r   r   	__class__s       r@   rY   AutoAugment.__init__y   s2     	*	**62rB   c                     U[         R                  :X  a  / SQ$ U[         R                  :X  a  / SQ$ U[         R                  :X  a  / SQ$ [	        SU S35      e)N)))r(   皙?   )r"   333333?	   )r)   rb      r*   rb   Nr+   皙?Nr+   rb   N))r(   rb      )r(   rb      r+   r`   N)r)   皙?   )rn   r"   ri   ra   ))r)   rb      rj   ))r(   ri   re   r+   r   N))r"   ro   rr   )r)   rb   ra   )rj   )r(   r`   rl   )rq   r%   r`   r   ))r"   r`   rc   rj   ))r+   r   Nrh   r,   rb   Nrs   )r%   rb   rp   )r&   r   ra   )rq   )r%   r      ))r%   ri   ra   )r)   ri   rk   ))r'   r`   rk   rv   ))r   rb   re   rs   )rt   rj   rm   rd   ru   rw   rg   ))r,   皙?N)r&   ro   rl   ))r"   ffffff?rx   )r    333333?rc   ))r'   ri   r	   )r'   ?rr   ))r         ?ra   r!   r{   rc   ))r*   r~   Nr+   r}   N))r   ro   rk   )r(   r|   rk   ))r%   r`   rr   )r$   rb   rk   ))r'   r|   rc   )r$   r{   rc   )rj   )r+   r~   N))r&   rb   rk   )r'   rb   re   ))r%   r{   rk   )r    r~   ra   ))r+   r|   N)r*   r`   N))r!   r`   rr   )r'   ro   rl   ))r$   r}   rl   )r%   ro   ra   ))r)   r~   rx   )r,   r   N)r+   ro   Nrf   )r   rj   ))r%   r}   rc   rj   )r*   ri   N)r)   ro   ra   ))r$   rz   rr   )r%   r{   r   ))r)   r`   re   r*   r}   N))r!   r}   rc   r   )r   )r)   ri   rr   )rh   ry   )r   r   ))r   r}   rp   )r,   ro   N)r   r}   ra   r,   r{   N)rj   )r)   rb   rl   r,   r}   Nrj   rj   )r"   r}   rr   )r   r   )r   )r,   r`   N))r   r}   re   )r)   ro   rl   )r   r   r   )r   )r)   r|   rr   ))r   ri   ra   r   )r   )r!   rb   rl   r   ))r&   r|   rr   r"   ri   rp   )r,   ri   N)r!   r   rx   ))r   r{   rl   )r)   r`   ra   )rv   r   ))r   r|   rk   )r    r}   rr   ))r   rz   rl   rv   ))r)   r{   rx   )r!   rb   rk   ))r   ri   rp   r   ))r   r{   rc   )r!   ri   rr   ))r   ri   re   )r*   r{   N))r   r{   rx   ry   zThe provided policy r.   )r   rN   rO   rP   r?   )r\   rT   s     r@   rZ   AutoAugment._get_policies   sk     &/// 6 (000 6 (--- 8 3F8;NOPPrB   num_bins
image_sizec                    [         R                  " SSU5      S4[         R                  " SSU5      S4[         R                  " SSUS   -  U5      S4[         R                  " SSUS   -  U5      S4[         R                  " SSU5      S4[         R                  " SSU5      S4[         R                  " SSU5      S4[         R                  " SSU5      S4[         R                  " SSU5      S4S	[         R                  " U5      US-
  S
-  -  R                  5       R	                  5       -
  S4[         R                  " SSU5      S4[         R
                  " S5      S4[         R
                  " S5      S4[         R
                  " S5      S4S.$ )Nr   r|   Tt ?r	   r         >@r}   ra   rp   F     o@)r   r   r    r!   r"   r$   r%   r&   r'   r(   r)   r*   r+   r,   )torchlinspacearangeroundr4   tensorr\   r   r   s      r@   _augmentation_spaceAutoAugment._augmentation_space   s^    ~~c394@~~c394@ >>#}z!}/LhWY]^ >>#}z!}/LhWY]^~~c4:DA >>#sH=tDnnS#x8$?S(;TB..c8<dCu||H5(Q,!9KLSSUYY[[]bcsH=uE"\\#.6c*E2||C(%0
 	
rB   transform_numc                     [        [        R                  " U S5      R                  5       5      n[        R                  " S5      n[        R                  " SS5      nXU4$ )znGet parameters for autoaugment transformation

Returns:
    params required by the autoaugment transformation
r	   )rx   rx   )r4   r   randintitemrand)r   	policy_idprobssignss       r@   
get_paramsAutoAugment.get_params   sK     mT:??AB	

4 a&&&rB   r   c           	         U R                   n[        R                  " U5      u  p4n[        U[        5      (       aI  [        U[
        [        45      (       a  [        U5      /U-  nOUb  U Vs/ s H  n[        U5      PM     nnU R                  [        U R                  5      5      u  pxn	U R                  SXE45      n
[        U R                  U   5       Hd  u  nu  pnX   U::  d  M  X   u  nnUb  [        X   R                  5       5      OSnU(       a  X   S:X  a  US-  n[        XUU R                  US9nMf     U$ s  snf )zq
    img (PIL Image or Tensor): Image to be transformed.

Returns:
    PIL Image or Tensor: AutoAugmented image.

   r   r         r#   )r   r/   get_dimensions
isinstancer   r4   floatr   lenr[   r   	enumerater   rA   r   )r\   r   r   channelsheightwidthftransform_idr   r   op_metair   pmagnitude_id
magnitudessignedr   s                     r@   forwardAutoAugment.forward   s-    yy"#"2"23"7%c6""$e--d}x/!*./$Qa$/%)__S5G%H"U**2?-6t}}\7R-S)A)Lx1}%,%5"
FFRF^E*":"?"?"ABdg	eh!m%IitGYGY`de .T 
 0s   -E c                 h    U R                   R                   SU R                   SU R                   S3$ )Nz(policy=, fill=))r]   rI   rT   r   )r\   s    r@   __repr__AutoAugment.__repr__  s/    ..))*(4;;-wtyykQRSSrB   )r   r   r[   rT   )rI   rJ   rK   rL   rM   r   rN   r   NEARESTr   r   r   rY   r   strr4   rZ   r   r   boolr   staticmethodr   r   r   rQ   __classcell__r]   s   @r@   r   r   h   s4   $ %6$>$>+<+D+D&*	
3!
3 )
3 tE{#	
3
 

3 
3XQ'XQ	eE#uhsm34eCQT<U6VVW	XXQt
C 
U38_ 
QUVY[`agimam[nVnQo 
& 
'# 
'%VV0C*D 
' 
'6 f 8T# T TrB   r   c                      ^  \ rS rSrSrSSS\R                  S4S\S\S	\S
\S\\	\
      SS4U 4S jjjrS\S\\\4   S\\\\\4   4   4S jrS\S\4S jrS\4S jrSrU =r$ )r   i  aB  RandAugment data augmentation method based on
`"RandAugment: Practical automated data augmentation with a reduced search space"
<https://arxiv.org/abs/1909.13719>`_.
If the image is torch Tensor, it should be of type torch.uint8, and it is expected
to have [..., 1 or 3, H, W] shape, where ... means an arbitrary number of leading dimensions.
If img is PIL Image, it is expected to be in mode "L" or "RGB".

Args:
    num_ops (int): Number of augmentation transformations to apply sequentially.
    magnitude (int): Magnitude for all the transformations.
    num_magnitude_bins (int): The number of different magnitude values.
    interpolation (InterpolationMode): Desired interpolation enum defined by
        :class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.NEAREST``.
        If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported.
    fill (sequence or number, optional): Pixel fill value for the area outside the transformed
        image. If given a number, the value is used for all bands respectively.
rx   rc      Nnum_opsr   num_magnitude_binsr   r   rU   c                 ^   > [         TU ]  5         Xl        X l        X0l        X@l        XPl        g rW   )rX   rY   r   r   r   r   r   )r\   r   r   r   r   r   r]   s         r@   rY   RandAugment.__init__2  s+     	""4*	rB   r   r   c                    [         R                  " S5      S4[         R                  " SSU5      S4[         R                  " SSU5      S4[         R                  " SSUS   -  U5      S4[         R                  " SSUS   -  U5      S4[         R                  " SSU5      S4[         R                  " SS	U5      S4[         R                  " SS	U5      S4[         R                  " SS	U5      S4[         R                  " SS	U5      S4S
[         R                  " U5      US-
  S-  -  R	                  5       R                  5       -
  S4[         R                  " SSU5      S4[         R                  " S5      S4[         R                  " S5      S4S.$ )Nr   Fr|   Tr   r	   r   r   r}   ra   rp   r   r-   r   r   r    r!   r"   r$   r%   r&   r'   r(   r)   r*   r+   r   r   r   r   r   r4   r   s      r@   r   RandAugment._augmentation_spaceA  s^    c*E2~~c394@~~c394@ >>#}z!}/LhWY]^ >>#}z!}/LhWY]^~~c4:DA >>#sH=tDnnS#x8$?S(;TB..c8<dCu||H5(Q,!9KLSSUYY[[]bcsH=uE"\\#.6c*E2
 	
rB   r   c           	      "   U R                   n[        R                  " U5      u  p4n[        U[        5      (       aI  [        U[
        [        45      (       a  [        U5      /U-  nOUb  U Vs/ s H  n[        U5      PM     nnU R                  U R                  XE45      n[        U R                  5       H  n[        [        R                  " [        U5      S5      R                  5       5      n	[        UR!                  5       5      U	   n
Xz   u  pUR"                  S:  a%  [        XR$                     R                  5       5      OSnU(       a!  [        R                  " SS5      (       a  US-  n['        XXR(                  US9nM     U$ s  snf )o
    img (PIL Image or Tensor): Image to be transformed.

Returns:
    PIL Image or Tensor: Transformed image.
r   r   r   rx   r   r#   )r   r/   r   r   r   r4   r   r   r   ranger   r   r   r   r   listkeysndimr   rA   r   )r\   r   r   r   r   r   r   r   _op_indexr   r   r   r   s                 r@   r   RandAugment.forwardT  sD    yy"#"2"23"7%c6""$e--d}x/!*./$Qa$/**4+B+BVOTt||$A5==Wt<AACDH7<<>*84G!(!1JDNOOVWDWj8==?@]`I%--400T!	C)CUCU\`aC % 
 0s   -Fc                     U R                   R                   SU R                   SU R                   SU R                   SU R
                   SU R                   S3nU$ )Nz	(num_ops=z, magnitude=z, num_magnitude_bins=, interpolation=r   r   )r]   rI   r   r   r   r   r   r\   ss     r@   r   RandAugment.__repr__o  sg    ~~&&' (||n4>>*#D$;$;#<t112dii[ 	
 rB   )r   r   r   r   r   )rI   rJ   rK   rL   rM   r   r   r4   r   r   r   rY   r   r   r   r   r   r   r   r   rQ   r   r   s   @r@   r   r     s    ( "$+<+D+D&*   	
 ) tE{# 
 
C 
U38_ 
QUVY[`agimam[nVnQo 
&6 f 6
# 
 
rB   r   c            	          ^  \ rS rSrSrS\R                  S4S\S\S\\	\
      SS4U 4S	 jjjrS
\S\\\\\4   4   4S jrS\S\4S jrS\4S jrSrU =r$ )r   i|  a  Dataset-independent data-augmentation with TrivialAugment Wide, as described in
`"TrivialAugment: Tuning-free Yet State-of-the-Art Data Augmentation" <https://arxiv.org/abs/2103.10158>`_.
If the image is torch Tensor, it should be of type torch.uint8, and it is expected
to have [..., 1 or 3, H, W] shape, where ... means an arbitrary number of leading dimensions.
If img is PIL Image, it is expected to be in mode "L" or "RGB".

Args:
    num_magnitude_bins (int): The number of different magnitude values.
    interpolation (InterpolationMode): Desired interpolation enum defined by
        :class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.NEAREST``.
        If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported.
    fill (sequence or number, optional): Pixel fill value for the area outside the transformed
        image. If given a number, the value is used for all bands respectively.
r   Nr   r   r   rU   c                 F   > [         TU ]  5         Xl        X l        X0l        g rW   )rX   rY   r   r   r   )r\   r   r   r   r]   s       r@   rY   TrivialAugmentWide.__init__  s!     	"4*	rB   r   c                    [         R                  " S5      S4[         R                  " SSU5      S4[         R                  " SSU5      S4[         R                  " SSU5      S4[         R                  " SSU5      S4[         R                  " SSU5      S4[         R                  " SSU5      S4[         R                  " SSU5      S4[         R                  " SSU5      S4[         R                  " SSU5      S4S[         R                  " U5      US-
  S	-  -  R	                  5       R                  5       -
  S4[         R                  " S
SU5      S4[         R                  " S5      S4[         R                  " S5      S4S.$ )Nr   FgGz?Tg      @@g     `@ra   r	   rl   r   r   r   )r\   r   s     r@   r   &TrivialAugmentWide._augmentation_space  sJ    c*E2~~c4:DA~~c4:DA >>#tX>E >>#tX>E~~c5(;TB >>#tX>EnnS$94@T8<dC..dH=tDu||H5(Q,!9KLSSUYY[[]bcsH=uE"\\#.6c*E2
 	
rB   r   c           	      &   U R                   n[        R                  " U5      u  p4n[        U[        5      (       aI  [        U[
        [        45      (       a  [        U5      /U-  nOUb  U Vs/ s H  n[        U5      PM     nnU R                  U R                  5      n[        [        R                  " [        U5      S5      R                  5       5      n[        UR                  5       5      U   n	Xy   u  pU
R                  S:  aG  [        U
[        R                  " [        U
5      S[        R                   S9   R                  5       5      OSnU(       a!  [        R                  " SS5      (       a  US-  n[#        XXR$                  US9$ s  snf )r   r   r   dtyper   rx   r   r#   )r   r/   r   r   r   r4   r   r   r   r   r   r   r   r   r   r   longrA   r   )r\   r   r   r   r   r   r   r   r   r   r   r   r   s                r@   r   TrivialAugmentWide.forward  sC    yy"#"2"23"7%c6""$e--d}x/!*./$Qa$/**4+B+BCu}}S\48==?@w||~&x0$-
 " *U]]3z?D

STYY[\ 	
 emmAt,,Iy@R@RY]^^ 0s   -Fc                     U R                   R                   SU R                   SU R                   SU R                   S3nU$ )Nz(num_magnitude_bins=r   r   r   )r]   rI   r   r   r   r   s     r@   r   TrivialAugmentWide.__repr__  sP    ~~&&' (""&"9"9!:t112dii[	 	
 rB   )r   r   r   )rI   rJ   rK   rL   rM   r   r   r4   r   r   r   rY   r   r   r   r   r   r   r   r   rQ   r   r   s   @r@   r   r   |  s    " #%+<+D+D&*			 )	 tE{#		
 
	 	
C 
DeFDL>Q9Q4R 
&_6 _f _:#  rB   r   c                   h  ^  \ rS rSrSrSSSSS\R                  S4S\S	\S
\S\S\	S\S\
\\      SS4U 4S jjjrS\S\\\4   S\\\\\	4   4   4S jr\R&                  R(                  S\4S j5       r\R&                  R(                  S\4S j5       rS\S\4S jrS\S\4S jrS\4S jrSrU =r$ )r   i  ax  AugMix data augmentation method based on
`"AugMix: A Simple Data Processing Method to Improve Robustness and Uncertainty" <https://arxiv.org/abs/1912.02781>`_.
If the image is torch Tensor, it should be of type torch.uint8, and it is expected
to have [..., 1 or 3, H, W] shape, where ... means an arbitrary number of leading dimensions.
If img is PIL Image, it is expected to be in mode "L" or "RGB".

Args:
    severity (int): The severity of base augmentation operators. Default is ``3``.
    mixture_width (int): The number of augmentation chains. Default is ``3``.
    chain_depth (int): The depth of augmentation chains. A negative value denotes stochastic depth sampled from the interval [1, 3].
        Default is ``-1``.
    alpha (float): The hyperparameter for the probability distributions. Default is ``1.0``.
    all_ops (bool): Use all operations (including brightness, contrast, color and sharpness). Default is ``True``.
    interpolation (InterpolationMode): Desired interpolation enum defined by
        :class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.NEAREST``.
        If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported.
    fill (sequence or number, optional): Pixel fill value for the area outside the transformed
        image. If given a number, the value is used for all bands respectively.
rr   r   TNseveritymixture_widthchain_depthalphaall_opsr   r   rU   c                    > [         TU ]  5         SU l        SUs=::  a  U R                  ::  d  O  [        SU R                   SU S35      eXl        X l        X0l        X@l        XPl        X`l	        Xpl
        g )Nr   r	   z!The severity must be between [1, z]. Got z	 instead.)rX   rY   _PARAMETER_MAXr?   r   r   r   r   r   r   r   )	r\   r   r   r   r   r   r   r   r]   s	           r@   rY   AugMix.__init__  sw     	 X4!4!44@ATAT@UU\]e\ffopqq *&
*	rB   r   r   c                 8   [         R                  " SSU5      S4[         R                  " SSU5      S4[         R                  " SUS   S-  U5      S4[         R                  " SUS   S-  U5      S4[         R                  " SSU5      S4S[         R                  " U5      US-
  S-  -  R                  5       R	                  5       -
  S	4[         R                  " S
SU5      S	4[         R
                  " S5      S	4[         R
                  " S5      S	4S.	nU R                  (       av  UR                  [         R                  " SSU5      S4[         R                  " SSU5      S4[         R                  " SSU5      S4[         R                  " SSU5      S4S.5        U$ )Nr   r|   Tr	   g      @r   r   rp   Fr   )	r   r   r    r!   r"   r(   r)   r*   r+   r}   )r$   r%   r&   r'   )r   r   r   r   r4   r   r   update)r\   r   r   r   s       r@   r   AugMix._augmentation_space  si    ~~c394@~~c394@ >>#z!}s/BHMtT >>#z!}s/BHMtT~~c4:DAu||H5(Q,!9KLSSUYY[[]bcsH=uE"\\#.6c*E2
 <<HH#(>>#sH#Et"L#nnS#x@$G!&S(!CT J"'..c8"Dd!K	 rB   c                 .    [         R                  " U5      $ rW   )r/   pil_to_tensorr\   r   s     r@   _pil_to_tensorAugMix._pil_to_tensor  s    s##rB   r   c                 .    [         R                  " U5      $ rW   )r/   to_pil_imager   s     r@   _tensor_to_pilAugMix._tensor_to_pil  s    ~~c""rB   paramsc                 .    [         R                  " U5      $ rW   )r   _sample_dirichlet)r\   r   s     r@   r  AugMix._sample_dirichlet  s    &&v..rB   orig_imgc                    U R                   n[        R                  " U5      u  p4n[        U[        5      (       aL  Un[        U[
        [        45      (       a  [        U5      /U-  nO0Ub  U Vs/ s H  n[        U5      PM     nnOU R                  U5      nU R                  U R                  XE45      n[        UR                  5      n	UR                  S/[        SUR                  -
  S5      -  U	-   5      n
U
R                  S5      /S/U
R                  S-
  -  -   nU R!                  ["        R$                  " U R&                  U R&                  /U
R(                  S9R+                  US   S5      5      nU R!                  ["        R$                  " U R&                  /U R,                  -  U
R(                  S9R+                  US   S5      5      USS2S4   R                  US   S/5      -  nUSS2S4   R                  U5      U
-  n[/        U R,                  5       GH  nU
nU R0                  S:  a  U R0                  O,[        ["        R2                  " SSSS9R5                  5       5      n[/        U5       H  n[        ["        R2                  " [7        U5      S5      R5                  5       5      n[        UR9                  5       5      U   nUU   u  nnUR                  S:  aH  [        U["        R2                  " U R:                  S["        R<                  S	9   R5                  5       5      OS
nU(       a!  ["        R2                  " SS5      (       a  US-  n[?        UUUU R@                  US9nM     URC                  USS2U4   R                  U5      U-  5        GM     UR                  U	5      RE                  URF                  S	9n[        U[        5      (       d  U RI                  U5      $ U$ s  snf )r   Nr	   rp   r   )devicer   r   )lowhighsizer   r   rx   r   r#   )%r   r/   r   r   r   r4   r   r   r   r   r   shapeviewmaxr   r	  r  r   r   r   r  expandr   r   r   r   r   r   r   r   r   rA   r   add_tor   r   )r\   r  r   r   r   r   r   r   r   	orig_dimsbatch
batch_dimsmcombined_weightsmixr   augdepthr   r   r   r   r   r   s                           r@   r   AugMix.forward!  sY    yy"#"2"28"<%h''C$e--d}x/!*./$Qa$/%%h/C**4+>+>PO	!s1sxx<33i?@jjm_sejj1n'==
 ""LL$**djj1%,,GNNzZ[}^`a

  11LL$**(:(::5<<PWWXbcdXegij
adGLL*Q-,-. 1gll:&.t))*AC(,(8(81(<D$$#emmXY`ahlFmFrFrFtBuE5\u}}S\4@EEGHw||~.x8%,W%5"
F "* *U]]4==$ejj%YZ__ab 
 emmAt44%IWitGYGY`de " HH%ad+00<sBC +  hhy!$$399$5(F++&&s++
U 0s   /O1c                     U R                   R                   SU R                   SU R                   SU R                   SU R
                   SU R                   SU R                   SU R                   S3nU$ )	Nz
(severity=z, mixture_width=z, chain_depth=z, alpha=z
, all_ops=r   r   r   )	r]   rI   r   r   r   r   r   r   r   r   s     r@   r   AugMix.__repr__[  s    ~~&&' (t112T--.tzzlt112dii[ 	
 rB   )r   r   r   r   r   r   r   r   )rI   rJ   rK   rL   rM   r   BILINEARr4   r   r   r   r   rY   r   r   r   r   r   r   jitunusedr   r   r  r   r   rQ   r   r   s   @r@   r   r     sC   , +<+E+E&*  	
   ) tE{# 
 ,C U38_ QUVY[`agimam[nVnQo 0 YY$V $ $ YY#& # #/ /6 /8 86 8t#  rB   r   )r1   enumr   typingr   r   r   r   r   r    r
   r/   r   __all__r   r   rA   r   nnModuler   r   r   r   rH   rB   r@   <module>r$     s      . .   0
]M	MM*/M@QMYabfglbmYnM` tT%((// tTnZ%((// ZzS SlUUXX__ UrB   