
    AVh                         d Z ddlZddlZddlmZ ddlmZ d Z ej                  d      Z	d Z
ej                  d	d       Zy)
z/Contains utility functions used by summary ops.    N)ops)
tf_loggingc                 F    ||}|D ]  }t        j                  ||         y)zAdds keys to a collection.

  Args:
    val: The value to add per each key.
    collections: A collection of keys to add.
    default_collections: Used if collections is None.
  N)r   add_to_collection)valcollectionsdefault_collectionskeys       U/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/python/ops/summary_op_util.pycollectr      s.     %K $c#s#$    z	[^-/\w\.]c                     | Jt         j                  d|       }|j                  d      }|| k7  rt        j                  d| d|d       |} | S )zCleans a tag. Removes illegal characters for instance.

  Args:
    name: The original tag name to be processed.

  Returns:
    The cleaned tag name.
  _/zSummary name z is illegal; using z	 instead.)_INVALID_TAG_CHARACTERSsublstripr   info)namenew_names     r   	clean_tagr   )   sR      
&**35Hs#H4ooX' (d	+r   c              #   6  K   t        |       } t        |      }|| ndj                  ||       }t        j                  |||d      5 }||j	                  d      }n!dj                  ||j	                  d            }||f ddd       y# 1 sw Y   yxY ww)a  Enters a scope used for the summary and yields both the name and tag.

  To ensure that the summary tag name is always unique, we create a name scope
  based on `name` and use the full scope name in the tag.

  If `family` is set, then the tag name will be '<family>/<scope_name>', where
  `scope_name` is `<outer_scope>/<family>/<name>`. This ensures that `family`
  is always the prefix of the tag (and unmodified), while ensuring the scope
  respects the outer scope from this summary was created.

  Args:
    name: A name for the generated summary node.
    family: Optional; if provided, used as the prefix of the summary tag name.
    default_name: Optional; if provided, used as default name of the summary.
    values: Optional; passed as `values` parameter to name_scope.

  Yields:
    A tuple `(tag, scope)`, both of which are unique and should be used for the
    tag and the scope for the summary to output.
  Nz{}/{}F)skip_on_eagerr   )r   formatr   
name_scoperstrip)r   familydefault_namevaluesscope_base_namescopetags          r   summary_scoper#   C   s     , 
4$V&"NDvt0L/
~~|V5B EJ~LLc NN65<<#45c
 ,  s   AB<B	BBB)NNN)__doc__
contextlibretensorflow.python.frameworkr   tensorflow.python.platformr   r   compiler   r   contextmanagerr#    r   r   <module>r,      sM    6  	 + 1$ %"**\2 4 $ $r   