a
    Sic                     @   sH   d Z ddlZddlmZ ddlmZ ejZejZd	ddZd
ddZ	dS )zScalar summaries and TensorFlow operations to create them.

A scalar summary stores a single floating-point value, as a rank-0
tensor.
    N)metadata)
summary_v2c              	   C   s   ddl m  m} |du r| }tj||d}|| n |||g< |jj	d|
||j||dW  d   W  d   S 1 s0    Y  W d   n1 s0    Y  dS )a  Create a legacy scalar summary op.

    Arguments:
      name: A unique name for the generated summary node.
      data: A real numeric rank-0 `Tensor`. Must have `dtype` castable
        to `float32`.
      display_name: Optional name for this summary in TensorBoard, as a
        constant `str`. Defaults to `name`.
      description: Optional long-form description for this summary, as a
        constant `str`. Markdown is supported. Defaults to empty.
      collections: Optional list of graph collections keys. The new
        summary op is added to these collections. Defaults to
        `[Graph Keys.SUMMARIES]`.

    Returns:
      A TensorFlow summary op.
    r   Ndisplay_namedescriptionscalar_summary)nametensorcollectionssummary_metadata)tensorflow.compat.v1compatv1r   create_summary_metadata
name_scopecontrol_dependenciesassert_scalarsummarytensor_summarycastfloat32)r   datar   r   r
   tfr    r   ^/var/www/html/django/DPS/env/lib/python3.9/site-packages/tensorboard/plugins/scalar/summary.pyop!   s    r   c           	      C   s   ddl m  m} t|}|jdkr4td|j |jjdvrPtd|jj	 |
|tj}|du rn| }tj||d}|j| }| }|jjd|  ||d	 |S )
a%  Create a legacy scalar summary protobuf.

    Arguments:
      name: A unique name for the generated summary, including any desired
        name scopes.
      data: A rank-0 `np.array` or array-like form (so raw `int`s and
        `float`s are fine, too).
      display_name: Optional name for this summary in TensorBoard, as a
        `str`. Defaults to `name`.
      description: Optional long-form description for this summary, as a
        `str`. Markdown is supported. Defaults to empty.

    Returns:
      A `tf.Summary` protobuf object.
    r   Nr   z.Expected scalar shape for data, saw shape: %s.)biufz!Cast %s to float is not supportedr   z%s/scalar_summary)tagr   r	   )r   r   r   nparrayshape
ValueErrordtypekindr   make_tensor_protoastyper   r   r   SummaryMetadata
FromStringSerializeToStringSummaryvalueadd)	r   r   r   r   r   r	   r   tf_summary_metadatar   r   r   r   pbE   s0    

r0   )NNN)NN)
__doc__numpyr!   tensorboard.plugins.scalarr   r   scalar	scalar_pbr   r0   r   r   r   r   <module>   s   
$