o
    ?e                     @   sZ   d Z ddlZddlZddlmZ ddlmZ dd ZedZ	dd	 Z
ejdd
dZdS )z/Contains utility functions used by summary ops.    N)ops)
tf_loggingc                 C   s&   |du r|}|D ]}t ||  qdS )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   Zadd_to_collection)valcollectionsZdefault_collectionskey r   f/home/www/facesmatcher.com/pyenv/lib/python3.10/site-packages/tensorflow/python/ops/summary_op_util.pycollect   s
   r	   z	[^-/\w\.]c                 C   s@   | durt d| }|d}|| krtd| |f  |} | S )zCleans a tag. Removes illegal characters for instance.

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

  Returns:
    The cleaned tag name.
  N_/z-Summary name %s is illegal; using %s instead.)_INVALID_TAG_CHARACTERSsublstripr   info)namenew_namer   r   r   	clean_tag)   s   
r   c                 c   s    t | } t |}|du r| nd|| }tj|||dd!}|du r)|d}n	d||d}||fV  W d   dS 1 sBw   Y  dS )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)Zskip_on_eagerr   )r   formatr   Z
name_scoperstrip)r   familydefault_namevaluesZscope_base_namescopetagr   r   r   summary_scopeC   s   "r   )NNN)__doc__
contextlibreZtensorflow.python.frameworkr   Ztensorflow.python.platformr   r	   compiler   r   contextmanagerr   r   r   r   r   <module>   s   
