
    Αi#                        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/ r\R                  R                  S5      r\R"                  " \\R$                  5      (       d   \	R&                  " 5       r\R                  R)                  \SSS5      rS r\" \5        S rSS jrS	 rS
\R4                  4S jr\R8                  4S jrSS jrg)    N~z.cachepaddledatasetc                      [         R                  " [        5        g ! [         a)  nUR                  [        R
                  :w  a  e  S nAg S nAff = fN)osmakedirs	DATA_HOMEOSErrorerrnoEEXIST)pathexcs     U/var/www/html/banglarbhumi/venv/lib/python3.13/site-packages/paddle/dataset/common.pymust_mkdirsr   6   s;    
I 99$ %s    
AAAc                    ^ [         R                  " 5       n[        U S5      m[        U4S jS5       H  nUR	                  U5        M     TR                  5         UR                  5       $ )Nrbc                  &   > T R                  S5      $ )N   )read)fs   r   <lambda>md5file.<locals>.<lambda>D   s    affTl    r   )hashlibmd5openiterupdateclose	hexdigest)fnamehash_md5chunkr   s      @r   md5filer%   A   sP    {{}HUDA*C0 1GGIr   c                    [         R                  " SU5      R                  5       n[        U[        5      (       a%  [         R                  " SU5      R                  5       n[
        R                  R                  [        U5      n[
        R                  R                  U5      (       d  [
        R                  " U5        [
        R                  R                  XCc  U R                  S5      S   OU5      n[
        R                  R                  U5      (       a  [        U5      U:X  a  U$ SnSn[
        R                  R                  U5      (       a  [        U5      U:X  Gd  [
        R                  R                  U5      (       a/  [        R                  R                  S[        U5       SU S	35        Xg:  a  US
-  nO[!        SU  SU 35      e[        R                  R                  SU SU  S35        [        R                  R                  S5         ["        R$                  " SU S SS9 nUR&                  R)                  S5      n	U	c7  [+        US5       n
[,        R.                  " UR0                  U
5        S S S 5        O[+        US5       n
Sn[3        U	5      n	X-  S
-   nUS:  a  US-  OS
nSn[4        R6                  R8                  R;                  USS9nUR=                  US9 HF  nU
R                  U5        US
-  nUR?                  U0 5        X-  S:X  d  M5  UR?                  U5        MH     S S S 5        S S S 5        [
        R                  R                  U5      (       d  GM
  [        U5      U:X  d  GM  [        R                  R                  S5        [        RB                  RE                  5         U$ ! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       N= f! [@         a  n S nAGM  S nAff = f)Nz^[a-zA-Z0-9_/\-]+$z^(?:(?!\.\.)[a-zA-Z0-9_/\.-])+$/r      zfile z  md5 
   zCannot download z within retry limit zCache file z not found, downloading z 
zBegin to download
GETT)timeoutfollow_redirectszcontent-lengthwbr      item)name)
chunk_sizez
Download finished
)#rematchgroup
isinstancestrr   r   joinr
   existsr	   splitr%   sysstderrwriteRuntimeErrorhttpxstreamheadersgetr   shutilcopyfileobjrawintr   hapiprogressbarProgressBar
iter_bytesr   	Exceptionstdoutflush)urlmodule_namemd5sum	save_namedirnamefilenameretryretry_limitrtotal_lengthr   r3   
total_iterlog_interval	log_indexbardataes                     r   downloadr_   J   s7   ((0+>DDFK)S!!HH0)

%' 	 ggll9k2G77>>'""
Gww||'83#iH 
ww~~hGH$5$?EKww~~h''GH,=,G77>>(##JJuWX%6$7vfXRHIQJE"3%';K=I  	

(#;C5D	
 	

./	sD4 yy}}-=>'h-**155!4 .- h-%)
'*<'8%1%>%B
0:RJ",Q % %&	$kk55AA&V B  %&LLJL$GDGGDM%NIJJy"5(71< #

9 5 %H . ww~~h''GH,=,GX JJ,-JJO5 .- .- 4  		sg   O/ -+O"N<:OBOO4O<O/ <
O
	O
O	O
O,(O/ ,O/ /
P Pc                  <   [        [        R                  5       V s/ s H  o R                  S5      (       a  M  U PM     sn  HR  nS[        [        R
                  " SU 35      5      ;   d  M+  [        R
                  " SU 35      R                  5         MT     g s  sn f )N__fetchzpaddle.dataset.)dirr   r   
startswith	importlibimport_modulerb   )xrP   s     r   	fetch_allrh      s~    v~~&&all4.@& c##ok]$CD
 
 ##ok]$CDJJL s
   BBz%05d.picklec                    [        U5      (       d  [        S5      e/ nSn[        U " 5       5       HM  u  pgUR                  U5        Xa:  d  M  Xa-  S:X  d  M'  [	        X%-  S5       nU" XH5        / nUS-  nSSS5        MO     U(       a   [	        X%-  S5       nU" XH5        SSS5        gg! , (       d  f       M  = f! , (       d  f       g= f)a  
you can call the function as:

split(paddle.dataset.cifar.train10(), line_count=1000,
    suffix="imikolov-train-%05d.pickle")

the output files as:

|-imikolov-train-00000.pickle
|-imikolov-train-00001.pickle
|- ...
|-imikolov-train-00480.pickle

:param reader: is a reader creator
:param line_count: line count for each file
:param suffix: the suffix for the output files, should contain "%d"
            means the id for each file. Default is "%05d.pickle"
:param dumper: is a callable function that dump object to file, this
            function will be called as dumper(obj, f) and obj is the object
            will be dumped, f is a file object. Default is cPickle.dump.
zdumper should be callable.r   wr+   N)callable	TypeError	enumerateappendr   )	reader
line_countsuffixdumperlinesindex_fidr   s	            r   r;   r;      s    , F455EG&(#Q?q~2f&,u 1 -, $ &"C(A5 )( 	 -,
 )(s   %B)	B;)
B8	;
C	c                     ^ ^^^ U UUU4S jnU$ )a  
Create a reader that yield element from the given files, select
a file set according trainer count and trainer_id

:param files_pattern: the files which generating by split(...)
:param trainer_count: total trainer count
:param trainer_id: the trainer rank id
:param loader: is a callable function that load object from file, this
            function will be called as loader(f) and f is a file object.
            Default is cPickle.load
c               3     >#    [        T5      (       d  [        S5      e[        R                  " T5      n U R                  5         / n[	        U 5       H/  u  p#UT-  T	:X  d  M  [        SU 35        UR                  U5        M1     U H*  n[        US5       nT" U5      nU S h  vN   S S S 5        M,     g  N! , (       d  f       M@  = f7f)Nzloader should be callable.zappend file: rW   )rk   rl   globsortrm   printrn   r   )
	file_listmy_file_listidxfnr   rs   files_patternloadertrainer_count
trainer_ids
         r   ro   $cluster_files_reader.<locals>.reader   s     899IIm,	 +GC]"j0bT*+##B' , Bb#!q	      ! s6   AC
"4C
B8$B6%B8)C
6B88
C	C
 )r   r   r   r   ro   s   ```` r   cluster_files_readerr      s    ! ! Mr   c                     U (       a&  [         R                  R                  U 5      (       a  U $ U(       a*  [        R                  R
                  R                  XU5      $ [        U  S35      e)Nz& not exists and auto download disabled)r   r   r:   r   r   commonr_   
ValueError)r   rO   r   rP   r_   s        r   _check_exists_and_downloadr      sO    t$$~~$$--cDDD6!GHIIr   r   )T)r   ry   r   re   r   pickler4   rD   r<   tempfiler@   r   paddle.dataset__all__r   
expanduserHOMEaccessW_OK
gettempdirr9   r
   r   r%   r_   rh   dumpr;   loadr   r   r   r   r   <module>r      s        	  	  
    
	ww# 
yyrww  DGGLLx9=	 I  AHM &36;; #N 6<[[BJr   