
    BVh                     \    d Z ddlZddlmZ dZd
dZd
dZ G d dej                  	      Zy)ah  TensorBoard Plugin asset abstract class.

TensorBoard plugins may need to provide arbitrary assets, such as
configuration information for specific outputs, or vocabulary files, or sprite
images, etc.

This module contains methods that allow plugin assets to be specified at graph
construction time. Plugin authors define a PluginAsset which is treated as a
singleton on a per-graph basis. The PluginAsset has an assets method which
returns a dictionary of asset contents. The tf.compat.v1.summary.FileWriter
(or any other Summary writer) will serialize these assets in such a way that
TensorBoard can retrieve them.
    N)ops__tensorboard_plugin_asset__c                 
   |t        j                         }| j                  st        d| j                  z        t
        | j                  z   }|j                  |      }|rit        |      dk7  rt        d|t        |      fz        |d   }t        ||       s/t        d| j                  d|j                  j                        |S  |        }|j                  ||       |j                  t
        | j                         |S )a  Acquire singleton PluginAsset instance from a graph.

  PluginAssets are always singletons, and are stored in tf Graph collections.
  This way, they can be defined anywhere the graph is being constructed, and
  if the same plugin is configured at many different points, the user can always
  modify the same instance.

  Args:
    plugin_asset_cls: The PluginAsset class
    graph: (optional) The graph to retrieve the instance from. If not specified,
      the default graph is used.

  Returns:
    An instance of the plugin_asset_class

  Raises:
    ValueError: If we have a plugin name collision, or if we unexpectedly find
      the wrong number of items in a collection.
  zClass %s has no plugin_name   *Collection for %s had %d items, expected 1r   z&Plugin name collision between classes z and )r   get_default_graphplugin_name
ValueError__name___PLUGIN_ASSET_PREFIXget_collectionlen
isinstance	__class__add_to_collection)plugin_asset_clsgraphname	containerinstances        V/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/python/summary/plugin_asset.pyget_plugin_assetr   $   s   ( ]!!#E		%	%
25E5N5NN
OO	 0 < <	<$""4()
9~Cc)n-. / /|Hh 01(1183E3E3N3NP Q Q 
/  !H	D(+	02B2N2NO	/    c                    | t        j                         } g }| j                  t              D ]U  }| j                  t        |z         }t	        |      dk7  rt        d|t	        |      fz        |j                  |d          W |S )a]  Retrieve all PluginAssets stored in the graph collection.

  Args:
    graph: Optionally, the graph to get assets from. If unspecified, the default
      graph is used.

  Returns:
    A list with all PluginAsset instances in the graph.

  Raises:
    ValueError: if we unexpectedly find a collection with the wrong number of
      PluginAssets.

  r   r   r   )r   r   r   r   r   r
   append)r   outr   
collections       r   get_all_plugin_assetsr   N   s     ]!!#E
#""#78 d%%&:T&ABJ
:!Cc*o./ 0 0JJz!} 
*r   c                   8    e Zd ZdZdZej                  d        Zy)PluginAsseta  This abstract base class allows TensorBoard to serialize assets to disk.

  Plugin authors are expected to extend the PluginAsset class, so that it:
  - has a unique plugin_name
  - provides an assets method that returns an {asset_name: asset_contents}
    dictionary. For now, asset_contents are strings, although we may add
    StringIO support later.

  LifeCycle of a PluginAsset instance:
  - It is constructed when get_plugin_asset is called on the class for
    the first time.
  - It is configured by code that follows the calls to get_plugin_asset
  - When the containing graph is serialized by the
    tf.compat.v1.summary.FileWriter, the writer calls assets and the
    PluginAsset instance provides its contents to be written to disk.
  Nc                     t               )a?  Provide all of the assets contained by the PluginAsset instance.

    The assets method should return a dictionary structured as
    {asset_name: asset_contents}. asset_contents is a string.

    This method will be called by the tf.compat.v1.summary.FileWriter when it
    is time to write the assets out to disk.
    )NotImplementedError)selfs    r   assetszPluginAsset.assets~   s     
r   )r   
__module____qualname____doc__r	   abcabstractmethodr$    r   r   r    r    j   s&    " +	  	 r   r    )	metaclass)N)	r'   r(   tensorflow.python.frameworkr   r   r   r   ABCMetar    r*   r   r   <module>r.      s3     +5 'T8 CKK  r   