
    h*>                     &   % S SK r S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKrS SK	r	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Jr  S SKJr  S SKrS SKrS SKJr  SSKJrJr  Sr SES	\!S
\\!\RD                  4   S\#SS4S jjr$SFS\\!\RD                  4   S\#S\!4S jjr%S\\!\RD                  4   S\!S\S\&4S jr'SGS\\!\RD                  4   S\\!   S\&4S jjr(SHS	\!S\#S\!4S jjr)S	\!S\\!   4S jr*   SIS	\!S\\!\RD                  4   S
\\\!\RD                  4      S\\!   S\#SS4S jjr+SJS\\!\RD                  4   S\&S\,\!   4S jjr-SJS\\!\RD                  4   S\!S\&S\,\!   4S jjr.  SKS\!S\\!\RD                  4   S
\\\!\RD                  4      S\\!   4S jjr/S \\!\RD                  4   S!\\!\RD                  4   S"\\!   SS4S# jr0\Rb                  \Rd                  S$.r3\4\!\#4   \5S%'   S \\!\RD                  4   S!\\!\RD                  4   S"\\!   SS4S& jr6\0\6S'.r7\4\!\\\!\RD                  4   \\!\RD                  4   \\!   /S4   4   \5S('   \ Rp                  \Rp                  \Rp                  S).r9\4\!\S*\4   4   \5S+'   S,S,S-S..r:\4\!\;\\!   \\!   4   4   \5S/'   S0\\!\RD                  4   S\;\!\\!   \\!   4   4S1 jr<  SLS \\!\RD                  4   S!\\\!\RD                  4      S2\&S\RD                  4S3 jjr=  SLS \\!\RD                  4   S!\\\!\RD                  4      S2\&S\\!\RD                  4   4S4 jjr>    SMS	\!S5\\!\RD                  4   S6\\\!\RD                  4      S
\\\!\RD                  4      S\\!   S2\&SS4S7 jjr?S8\S\!4S9 jr@\" S:\!\A5      rB   SNS;\BS<\\!   S=\\\B      S>\\!   S\B4
S? jjrCSOS@\\!\RD                  4   SA\#S\R                  4SB jjrESC\R                  S\R                  4SD jrGg)P    N)Iterable)AnyCallableIOOptionalTypeVarUnion)urlparse)tqdm   )#_download_file_from_remote_location_is_remote_location_availablezpytorch/visionurlfilename
chunk_sizereturnc                    [         R                  R                  [         R                  R                  U S[        0S95       n[        US5       n[        UR                  SSS9 nUR                  U5      =n(       aE  UR                  U5        UR                  [        U5      5        UR                  U5      =n(       a  ME  S S S 5        S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       N(= f! , (       d  f       g = f)N
User-AgentheaderswbBT)totalunit
unit_scale)urllibrequesturlopenRequest
USER_AGENTopenr   lengthreadwriteupdatelen)r   r   r   responsefhpbarchunks          R/var/www/auris/envauris/lib/python3.13/site-packages/torchvision/datasets/utils.py_urlretriever,      s    			 6 6s\S]D^ 6 _	`dl(D!RHOO#Z^)_cg#==44%4CJ' $==44%4 *`! 
a	`)_)_!! 
a	`s=   C>C-%ACC-C>
C*&C--
C;	7C>>
Dfpathc                 :   [         R                  " SS9n[        U S5       nUR                  U5      =n(       a+  UR	                  U5        UR                  U5      =n(       a  M+  S S S 5        UR                  5       $ ! , (       d  f       UR                  5       $ = f)NF)usedforsecurityrb)hashlibmd5r!   r#   r%   	hexdigest)r-   r   r2   fr*   s        r+   calculate_md5r5   #   s~     ++e
,C	eT	avvj))e)JJu vvj))e) 
 ==? 
	 ==?s   AA==
Br2   kwargsc                      U[        U 40 UD6:H  $ N)r5   )r-   r2   r6   s      r+   	check_md5r9   .   s    -0000    c                 j    [         R                  R                  U 5      (       d  gUc  g[        X5      $ )NFT)ospathisfiler9   )r-   r2   s     r+   check_integrityr?   2   s+    77>>%  
{U  r:   max_hopsc           	         U nS[         S.n[        US-   5       H|  n[        R                  R	                  [        R                  R                  XS95       nUR                  U :X  d  UR                  c  U sS S S 5        s  $ UR                  n S S S 5        M~     [        SU SU SU  S35      e! , (       d  f       M  = f)	NHEAD)Methodr      r   zRequest to z
 exceeded z( redirects. The last redirect points to .)r    ranger   r   r   r   r   RecursionError)r   r@   initial_urlr   _r'   s         r+   _get_redirect_urlrJ   :   s    Kz:G8a< ^^##FNN$:$:3$:$PQU]||s"hll&: RQ ,,C	 RQ ! +j
:bcfbgghi
 	
 RQs   B/B//
B>	c                     [        U 5      n[        R                  " SUR                  5      c  g [        R                  " SUR                  5      nUc  g UR                  S5      $ )Nz(drive|docs)[.]google[.]comz/file/d/(?P<id>[^/]*)id)r
   rematchnetlocr=   group)r   partsrN   s      r+   _get_google_drive_file_idrR   J   sP    SME	xx.=EHH-uzz:E};;tr:   rootmax_redirect_hopsc                    [         R                  R                  U5      nU(       d  [         R                  R                  U 5      n[         R                  " [         R                  R                  X5      5      n[         R                  " USS9  [        XS5      (       a  g[        5       (       a  [        XP5        O/[        XS9n [        U 5      nUb  [        XaX#5      $  [        X5        [        XS5      (       d  ['        S	5      eg! [        R                  R                   ["        4 a2  nU SS S:X  a"  U R%                  SS5      n [        X5         SnANkUeSnAff = f)
a  Download a file from a url and place it in root.

Args:
    url (str): URL to download file from
    root (str): Directory to place downloaded file in
    filename (str, optional): Name to save the file under. If None, use the basename of the URL
    md5 (str, optional): MD5 checksum of the download. If None, do not check
    max_redirect_hops (int, optional): Maximum number of redirect hops allowed
Texist_okN)r@      httpszhttps:zhttp:File not found or corrupted.)r<   r=   
expanduserbasenamefspathjoinmakedirsr?   r   r   rJ   rR   download_file_from_google_driver,   r   errorURLErrorOSErrorreplaceRuntimeError)r   rS   r   r2   rT   r-   file_ides           r+   download_urlrh   W   s     77d#D77##C(IIbggll423EKKt$ u""$&&+E7  @ ,C027(PP	$ 5&&9:: ' %%w/ 	2Aw'!kk(G4S((	s   D $E)&EEEprefixc           	         [         R                  R                  U 5      n [         R                  " U 5       Vs/ s HH  n[         R                  R	                  [         R                  R                  X5      5      (       d  MF  UPMJ     nnUSL a/  U Vs/ s H"  n[         R                  R                  X5      PM$     nnU$ s  snf s  snf )zList all directories at a given root

Args:
    root (str): Path to directory whose folders need to be listed
    prefix (bool, optional): If true, prepends the path to each result, otherwise
        only returns the name of the directories found
T)r<   r=   r[   listdirisdirr^   )rS   ri   pdirectoriesds        r+   list_dirrp      s     77d#D jj.W."''--T@U2V1.KW~6ABkrww||D,kB XBs   AB?B?)Csuffixc           	         [         R                  R                  U 5      n [         R                  " U 5       Vs/ s H`  n[         R                  R	                  [         R                  R                  X5      5      (       d  MF  UR                  U5      (       d  M^  UPMb     nnUSL a/  U Vs/ s H"  n[         R                  R                  X5      PM$     nnU$ s  snf s  snf )a  List all files ending with a suffix at a given root

Args:
    root (str): Path to directory whose folders need to be listed
    suffix (str or tuple): Suffix of the files to match, e.g. '.png' or ('.jpg', '.png').
        It uses the Python "str.endswith" method and is passed directly
    prefix (bool, optional): If true, prepends the path to each result, otherwise
        only returns the name of the files found
T)r<   r=   r[   rk   r>   r^   endswith)rS   rq   ri   rm   filesro   s         r+   
list_filesru      s     77d#D

4(i(1BGGNN277<<;P,QQVWV`V`agVhQ(Ei~0561d&6L j6s   ACCC*)Crf   c                     SSK n[        R                  R                  U5      nU(       d  U n[        R                  " [        R                  R                  X5      5      n[        R                  " USS9  [        XS5      (       a  gUR                  XS[        S9  [        XS5      (       d  [        S5      eg! [         a    [        S5      ef = f)	aN  Download a Google Drive file from  and place it in root.

Args:
    file_id (str): id of file to be downloaded
    root (str): Directory to place downloaded file in
    filename (str, optional): Name to save the file under. If None, use the id of the file.
    md5 (str, optional): MD5 checksum of the download. If None, do not check
r   Nz`To download files from GDrive, 'gdown' is required. You can install it with 'pip install gdown'.TrV   F)rL   outputquiet
user_agentrZ   )gdownModuleNotFoundErrorre   r<   r=   r[   r]   r^   r_   r?   downloadr    )rf   rS   r   r2   rz   r-   s         r+   r`   r`      s    
 77d#DIIbggll423EKKt$u""	NNg5ZNP5&&9:: '#  
n
 	

s   B8 8C	from_pathto_pathcompressionc                     [         R                  " X(       a  SUSS   3OS5       nUR                  U5        S S S 5        g ! , (       d  f       g = f)Nzr:rD   r)tarfiler!   
extractall)r}   r~   r   tars       r+   _extract_tarr      s@     
i;2k!"o%6!7C	PTWw 
Q	P	Ps   A
A).bz2.xz_ZIP_COMPRESSION_MAPc                     [         R                  " U SU(       a	  [        U   O[         R                  S9 nUR	                  U5        S S S 5        g ! , (       d  f       g = f)Nr   )r   )zipfileZipFiler   
ZIP_STOREDr   )r}   r~   r   zips       r+   _extract_zipr      sG     
3$8$EZaZlZl
	w
 
 
s   A
A).tarz.zip_ARCHIVE_EXTRACTORS)r   .gzr   ._COMPRESSED_FILE_OPENERS)r   r   )r   r   )z.tbzz.tbz2z.tgz_FILE_TYPE_ALIASESfilec                    [         R                  " U 5      R                  nU(       d  [        SU  S35      eUS   nU[        ;   a  U/[        U   Q7$ U[
        ;   a  X"S4$ U[        ;   a)  [        U5      S:  a  US   nU[
        ;   a  X2-   X24$ USU4$ [        [        [        5      [        [
        5      -  [        [        5      -  5      n[        SU SU S	35      e)
zDetect the archive type and/or compression of a file.

Args:
    file (str): the filename

Returns:
    (tuple): tuple of suffix, archive type, and compression

Raises:
    RuntimeError: if file has no suffix or suffix is not supported
zFile 'zP' has no suffixes that could be used to detect the archive type and compression.NrD   z&Unknown compression or archive type: 'z'.
Known suffixes are: 'z'.)
pathlibPathsuffixesre   r   r   r   r&   sortedset)r   r   rq   suffix2valid_suffixess        r+   _detect_file_typer      s    ||D!**HTFjk
 	
 b\F ##4+F344 $$t## ))x=1rlG --'88tV##C 23c:M6NNQTUmQnnoN
?xG`ao`pprs
ttr:   remove_finishedc                    [        U 5      u  p4nU(       d  [        SU S35      eUc>  [        R                  " [        R
                  " U 5      R                  X4b  UOS5      5      n[        U   nU" U S5       n[        US5       nUR                  UR                  5       5        SSS5        SSS5        U(       a  [        R                  " U 5        [        R                  " U5      $ ! , (       d  f       NI= f! , (       d  f       NR= f)a  Decompress a file.

The compression is automatically detected from the file name.

Args:
    from_path (str): Path to the file to be decompressed.
    to_path (str): Path to the decompressed file. If omitted, ``from_path`` without compression extension is used.
    remove_finished (bool): If ``True``, remove the file after the extraction.

Returns:
    (str): Path to the decompressed file.
z*Couldn't detect a compression from suffix rE   N r0   r   )r   re   r   r   r<   r]   rd   r   r!   r$   r#   remove)	r}   r~   r   rq   archive_typer   compressed_file_openerrfhwfhs	            r+   _decompressr   "  s    " ):)(D%F+GxqQRR,,ryy3;;FTlLrtuv 6kB		4	0Cgt9LPS		#((* :M	0 
		)<<   :M9L	0	0s$   8C9 C(%C9(
C6	2C99
Dc           
      .  ^  S[         R                  S[        [        [         R                  4   4U 4S jjnUc  [        R
                  R                  T 5      n[        T 5      u  pEnU(       d^  [        T [        R
                  R                  U[        R
                  R                  T 5      R                  US5      5      US9nU" U5      $ [        U   nU" T X5        U(       a  [        R                  " T 5        U" [         R                  " U5      5      $ )a  Extract an archive.

The archive type and a possible compression is automatically detected from the file name. If the file is compressed
but not an archive the call is dispatched to :func:`decompress`.

Args:
    from_path (str): Path to the file to be extracted.
    to_path (str): Path to the directory the file will be extracted to. If omitted, the directory of the file is
        used.
    remove_finished (bool): If ``True``, remove the file after the extraction.

Returns:
    (str): Path to the directory the file was extracted to.
ret_pathr   c                 ^   > [        T[        5      (       a  [        R                  " U 5      $ U $ r8   )
isinstancestrr<   r]   )r   r}   s    r+   path_or_str$extract_archive.<locals>.path_or_strZ  s$    i%%99X&&Or:   r   )r   )r   r   r	   r   r<   r=   dirnamer   r   r^   r\   rd   r   r   )	r}   r~   r   r   rq   r   r   r   	extractors	   `        r+   extract_archiver   F  s    (gll uS',,5F/G  ''//),(9)(D%F+GGLL"''"2"29"="E"Efb"QR+

 8$$ $L1Ii.
		)w||G,--r:   download_rootextract_rootc                    [         R                  R                  U5      nUc  UnU(       d  [         R                  R                  U 5      n[	        XX45        [         R                  R                  X5      n[        XbU5        g r8   )r<   r=   r[   r\   rh   r^   r   )r   r   r   r   r2   r   archives          r+   download_and_extract_archiver   v  s`     GG&&}5M$77##C(X3ggll=3GG?;r:   iterablec           	      n    SSR                  U  Vs/ s H  n[        U5      PM     sn5      -   S-   $ s  snf )N'z', ')r^   r   )r   items     r+   iterable_to_strr     s1    H=HDc$iH=>>DD=s   2
Tvalueargvalid_values
custom_msgc                     [        U [        5      (       d,  Uc  SnOSnUR                  [        U 5      US9n[	        U5      eUc  U $ X;  a,  Ub  UnOSnUR                  X[        U5      S9n[	        U5      eU $ )Nz'Expected type str, but got type {type}.z:Expected type str for argument {arg}, but got type {type}.)typer   zPUnknown value '{value}' for argument {arg}. Valid values are {{{valid_values}}}.)r   r   r   )r   r   formatr   
ValueErrorr   )r   r   r   r   msgs        r+   verify_str_argr     s     eS!!;;CNCjjd5ksj3o !CdC**5P\@]*^CoLr:   	file_nameslice_channelsc                    [        U S5       nUR                  5       R                  5       nUS;  a  [        S5      e[        R
                  " SUR                  5       5      nU(       d  [        S5      eS UR                  5        5       u  pV[        UR                  5       R                  5       5      nUS:  a  SnU* nOS	n[        R                  " X(S
-   S9n	SSS5        WS:X  a  SOSn
W	R                  WWU
5      R                  SSS5      n	[        R                  " U	SS9n	U	SU2SS2SS24   n	U	R                  [        R                  5      $ ! , (       d  f       N~= f)a0  Read file in .pfm format. Might contain either 1 or 3 channels of data.

Args:
    file_name (str): Path to the file.
    slice_channels (int): Number of channels to slice out of the file.
        Useful for reading different data formats stored in .pfm files: Optical Flows, Stereo Disparity Maps, etc.
r0   )   PFs   PfzInvalid PFM files   ^(\d+)\s(\d+)\s$zMalformed PFM header.c              3   8   #    U  H  n[        U5      v   M     g 7fr8   )int).0dims     r+   	<genexpr>_read_pfm.<locals>.<genexpr>  s     7$6SC$6s   r   <>r4   )dtypeNr      rD   r   )axis)r!   readlinerstripr   rM   rN   	Exceptiongroupsfloatnpfromfilereshape	transposeflipastypefloat32)r   r   r4   header	dim_matchwhscaleendiandatapfm_channelss              r+   	_read_pfmr     s,    
i	!$$&'/00HH11::<@	3447I$4$4$67ajjl))+,19FFEF{{1SL1# 
& %1QL<<1l+55aA>D774a DA%&D;;rzz""1 
	s   CE
Etc                 >   U R                  5       R                  [        R                  5      R                  " / U R                  QU R                  5       P76 R                  S5      R                  " / U R                  S S QSP76 R                  U R                  5      $ )Nr   )
contiguousviewtorchuint8shapeelement_sizer   r   )r   s    r+   _flip_byte_orderr     s~    	EKK(--IqwwI8HINNrRWWjYZY`Y`adbdYejgijoopqpwpwxr:   )i   )i   r8   )r   )NNr   )F)NN)NF)NNNF)NNN)r   )Hbz2gzipr1   lzmar<   os.pathr   rM   r   r   urllib.errorurllib.requestr   collections.abcr   typingr   r   r   r   r   r	   urllib.parser
   numpyr   r   torch.utils.model_zoor   _internally_replaced_utilsr   r   r    r   r   r   r,   r5   boolr9   r?   rJ   rR   rh   listrp   ru   r`   r   	ZIP_BZIP2ZIP_LZMAr   dict__annotations__r   r   r!   r   r   tupler   r   r   r   r   bytesr   r   ndarrayr   Tensorr    r:   r+   <module>r     s   
    	   	      $ > > !   & k
(c (U3+<%= (3 (_c (sGLL01 s UX 1U3,- 1C 13 14 1!5gll!23 !(3- !SW !
3 
# 
c 
 
3 
8C= 
  482;	2;
W\\!
"2; uS',,./02; 
#	2;
 2; 
2;j5gll*+ T d3i U3,- s D UYZ]U^ ( 48	";";
W\\!
""; uS',,./0"; 
#	";J S',,&' 27W\\8I2J YabeYf 	  ( d38n  S',,&' 27W\\8I2J YabeYf 	  w T#xsGLL/@)A5gllIZC[]efi]j(kmq(qrrs 
 HH9999: $sHS"W$556  F DeHSM8C=$@AAB (uE#w||"34 (usHSMS[\_S`?`9a (uZ 37!!!S',,&'!!eC-./!! !! \\	!!L 37!-.S',,&'-.eC-./-. -. 3	-.f 8<37!<	<gll*+< 5gll!234< uS',,./0	<
 
#< < 
<(Eh E3 E Ce
 *. $		# 8A;' 	
 8!#sGLL01 !#3 !#rzz !#H  r:   