§
    P„jî  ã                   óà   — d Z ddlZddlmZ ddlZddlmZ  ej        ej	        j
        j        ej	        j
        j        ¦  «         ej        d„ ¦   «         Z G d„ dej        j        ¦  «        ZdS )zGContains TensorFlow or Google-specific utilities for Gin configuration.é    N)Úconfig)Úsummary_pb2c                 ó˜   — t          j        ¦   «         t          j        j                             ¦   «         f}t          j        || ¦  «        S )N)r   Úcurrent_scope_strÚtfÚcompatÚv1Úget_default_graphÚsingleton_value)ÚconstructorÚkeys     úQ/root/disk_3tb/conda_envs/Huy-visual/lib/python3.11/site-packages/gin/tf/utils.pyÚsingleton_per_graphr   !   s8   € å	Ô	!Ñ	#Ô	#¥R¤Y¤\×%CÒ%CÑ%EÔ%EÐF€#Ý	Ô	  [Ñ	1Ô	1Ð1ó    c                   ó*   — e Zd ZdZ	 	 	 	 dd„Zdd„ZdS )	ÚGinConfigSaverHooka  A SessionRunHook that saves and summarizes the operative config.

  This hook will save Gin's operative configuration to a specified directory, as
  well as optionally summarizing it so that it will appear in TensorBoard's
  "Text" tab.

  The hook should only be supplied to the chief worker in distributed training
  setups to prevent multiple events files from being created. Similarly, if hook
  methods are called explicitly (if not using tf.training.MonitoredSession),
  they should only be called on the chief worker.
  Úoperative_configTNc                 óL   — || _         || _        || _        || _        || _        dS )a©  Construct the GinConfigSaverHook.

    Args:
      output_dir: The directory in which to save the operative config. This
        should in general be the same as the directory in which summaries are
        stored (and thus may be different for train vs. eval jobs.
      base_name: The base name (name excluding path and extension) of the file
        where this hook will write the operative config. Also used as the
        summary tag if summarizing the config for display in TensorBoard.
      summarize_config: Whether to save a summary of the operative config that
        will be loaded by TensorBoard and displayed in its "Text" tab.
      summary_writer: A tf.summary.FileWriter object to use for writing
        summaries. If `None` (default), a FileWriter object for `output_dir`
        will be created/retrieved by the tf.summary.FileWriterCache associated
        with `output_dir` in `after_create_session`.
      include_step_in_filename: A bool indicating whether to include the global
        step when writing out the operative config file. When True, the filename
        will be {base_name}-{global_step}.gin; when False the filename will be
        {base_name}.gin.
    N)Ú_output_dirÚ
_base_nameÚ_summarize_configÚ_summary_writerÚ_include_step_in_filename)ÚselfÚ
output_dirÚ	base_nameÚsummarize_configÚsummary_writerÚinclude_step_in_filenames         r   Ú__init__zGinConfigSaverHook.__init__4   s1   € ð4 "€DÔØ€D„OØ-€DÔØ)€DÔØ%=€DÔ"Ð"Ð"r   c                 ó²  — t          j        ¦   «         }t          j        j                             | j        ¦  «        s)t          j        j                             | j        ¦  «         d}|�?t          j        j	        j
                             ¦   «         }|�|                     |¦  «        }| j        r| j        ›d|›d�}n
d| j        z  }t          j                             | j        |¦  «        }t          j        j                             |d¦  «        5 }|                     |¦  «         ddd¦  «         n# 1 swxY w Y   | j        �rt          j        |¦  «        }	t-          j        ¦   «         }
d|
j        _        d|
j        _        t          j        j	                             |	¦  «        }t-          j        ¦   «         }|j                             d	| j        z   ||
¬
¦  «         | j        s8t          j        j	        j         j!         "                    | j        ¦  «        | _        | j         #                    ||¦  «         | j         $                    ¦   «          dS dS )zBWrites out Gin's operative config, and maybe adds a summary of it.r   Nú-z.ginz%s.ginÚwÚtexts   {}zgin/)ÚtagÚtensorÚmetadata)%r   Úoperative_config_strr   ÚioÚgfileÚisdirr   Úmakedirsr   r	   ÚtrainÚget_global_stepÚrunr   r   ÚosÚpathÚjoinÚGFileÚwriter   Úmarkdownr   ÚSummaryMetadataÚplugin_dataÚplugin_nameÚcontentÚmake_tensor_protoÚSummaryÚvalueÚaddr   ÚsummaryÚFileWriterCacheÚgetÚadd_summaryÚflush)r   ÚsessionÚcoordÚ
config_strÚglobal_step_valÚglobal_stepÚfilenameÚconfig_pathÚfÚmd_config_strÚsummary_metadataÚtext_tensorr>   s                r   Úafter_create_sessionz'GinConfigSaverHook.after_create_sessionT   sQ  € åÔ,Ñ.Ô.€JÝŒ5Œ;×Ò˜TÔ-Ñ.Ô.ð -Ý„e„k×Ò˜4Ô+Ñ,Ô,Ð,Ø€OØÐÝ”I”LÔ&×6Ò6Ñ8Ô8€kØ	Ð	 Ø!Ÿ+š+ kÑ2Ô2ˆØÔ%ð ,Ø $¤  °°°ÐA€h€hà˜DœOÑ+€hÝ”'—,’,˜tÔ/°Ñ:Ô:€KÝ	ŒŒ×	Ò	˜;¨Ñ	,Ô	,ð °Ø‡g‚gˆjÑÔÐðð ð ñ ô ð ð ð ð ð ð øøøð ð ð ð ð Ôñ #Ý”o jÑ1Ô1€mÝ$Ô4Ñ6Ô6ÐØ17ÐÔ"Ô.Ø-2ÐÔ"Ô*Ý”I”L×2Ò2°=ÑAÔA€kÝÔ#Ñ%Ô%€gØ„m×ÒØ�t”Ñ&ØØ#ð ñ %ô %ð %ð Ô!ð õ  "œyœ|Ô3ÔC×GÒGØÔñ ô  ˆÔà
Ô×&Ò& w°Ñ@Ô@Ð@Ø
Ô× Ò Ñ"Ô"Ð"Ð"Ð"ð%#ð #s   ÄD4Ä4D8Ä;D8)r   TNT)NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r    rN   © r   r   r   r   '   sU   € € € € € ð
ð 
ð ,Ø $Ø"Ø(,ð>ð >ð >ð >ð@$#ð $#ð $#ð $#ð $#ð $#r   r   )rR   r0   Úginr   Ú
tensorflowr   Útensorflow.core.frameworkr   Úregister_file_readerr)   r*   r3   ÚexistsÚconfigurabler   Ú	estimatorÚSessionRunHookr   rS   r   r   ú<module>r\      sÐ   ðð  NÐ Mà 	€	€	€	à Ð Ð Ð Ð Ð à Ð Ð Ð ð 2Ð 1Ð 1Ð 1Ð 1Ð 1ð
 €Ô ˜BœEœKÔ-¨r¬u¬{Ô/AÑ BÔ BÐ Bð Ôð2ð 2ñ Ôð2ð
Q#ð Q#ð Q#ð Q#ð Q#˜œÔ4ñ Q#ô Q#ð Q#ð Q#ð Q#r   