
    &Vf                     .    d Z ddlmZ d Zd Zd Zd ZdS )zUtilities for graph plugin.    )	graph_pb2c                     | d|S )N/ )prefixop_names     a/var/www/html/software/conda/lib/python3.11/site-packages/tensorboard/plugins/graph/graph_util.py_prefixed_op_namer
      s    ffgg&&    c                     | d|S )aq  Returns function name prefixed with `prefix`.

    For function libraries, which are often created out of autographed Python
    function, are factored out in the graph vis. They are grouped under a
    function name which often has a shape of
    `__inference_[py_func_name]_[numeric_suffix]`.

    While it does not have some unique information about which graph it is from,
    creating another wrapping structure with graph prefix and "/" is less than
    ideal so we join the prefix and func_name using underscore.

    TODO(stephanwlee): add business logic to strip "__inference_" for more user
    friendlier name
    _r   )r   	func_names     r	   _prefixed_func_namer      s     ffii((r   c                 B    |j         D ]}|j                                         }|                    |           t           |j                  |_         fd|j        D             |j        d d <   |j        dk    rG|j        d         r:t           |j        d         j	        j                  |j        d         j	        _        |j
        j        D ]Y}|j
        j                                        }|                    |           t           |j        j                  |j        _        Z|j
        j        D ]i}|j
        j                                        }|                    |           t           |j                  |_        t           |j                  |_        jd S )Nc                 0    g | ]}t          |          S r   )r
   ).0
input_namer   s     r	   
<listcomp>z-_add_with_prepended_names.<locals>.<listcomp>/   s1     
 
 
6@fj11
 
 
r   PartitionedCallf)nodeaddCopyFromr
   nameinputopattrr   funclibraryfunction	signaturegradientfunction_namegradient_func)	r   graph_to_adddestination_graphr   new_noder   new_funcr"   new_gradients	   `        r	   _add_with_prepended_namesr*   *   s   !  $)--//$)&$)<<
 
 
 
DHJ
 
 
qqq ;+++c0B++>c"',, ,HM##(
 $- 
 
$,599;;$"5H&+#
 #
 !(1 

 

(09==??h'''%8&&
 &
" &9&&
 &
""

 

r   c                    t          |           dk    r| d         S t          |           dk    rt          j                    S t          j                    }| d         j        j        r%|j                            | d         j                   t          |           D ]E\  }}|j        j        |j        j        k    rt          d          t          d|dz   z  ||           F|S )a  Merges GraphDefs by adding unique prefix, `graph_{ind}`, to names.

    All GraphDefs are expected to be of TensorBoard's.

    When collecting graphs using the `tf.summary.trace` API, node names are not
    guranteed to be unique.  When non-unique names are not considered, it can
    lead to graph visualization showing them as one which creates inaccurate
    depiction of the flow of the graph (e.g., if there are A -> B -> C and D ->
    B -> E, you may see {A, D} -> B -> E).  To prevent such graph, we checked
    for uniquenss while merging but it resulted in
    https://github.com/tensorflow/tensorboard/issues/1929.

    To remedy these issues, we simply "apply name scope" on each graph by
    prefixing it with unique name (with a chance of collision) to create
    unconnected group of graphs.

    In case there is only one graph def passed, it returns the original
    graph_def. In case no graph defs are passed, it returns an empty GraphDef.

    Args:
      graph_defs: TensorBoard GraphDefs to merge.

    Returns:
      TensorBoard GraphDef that merges all graph_defs with unique prefixes.

    Raises:
      ValueError in case GraphDef versions mismatch.
       r   z/Cannot combine GraphDefs of different versions.zgraph_%d)	lenr   GraphDefversionsproducerr   	enumerate
ValueErrorr*   )
graph_defsdst_graph_defindex	graph_defs       r	   merge_graph_defsr7   P   s    : :!!}	ZA		!###&((M!}& @''
1(>???%j11 
 
y!*i.@.IIINOOO!%!)$	
 	
 	
 	
 r   N)__doc__tensorboard.compat.protor   r
   r   r*   r7   r   r   r	   <module>r:      sf    " ! . . . . . .' ' ') ) )$#
 #
 #
L1 1 1 1 1r   