
    &Vf~                     R    d Z ddlZddlZddlmZ ddlmZ  G d d          Z	d Z
dS )zImplementation for tensorboard.summary.Writer and related symbols.

This provides a TensorBoard-native summary writing API that only depends
on numpy and not any particular ML framework.
    N)metadata)_outputc                   8    e Zd ZdZd Zd Zd Zd ZddddZdS )	WriterzWrites summary data for visualization in TensorBoard.

    This class is not thread-safe.

    TODO(#4581): This API should be considered EXPERIMENTAL and subject to
    backwards-incompatible changes without notice.
    c                     t          |t          j                  r|| _        nAt          |t                    rt          j        |          | _        nt          d|z            d| _        dS )aa  Constructs a Writer.

        Args:
          output: `tensorboard.summary.Output` object, or a string which will be
            interpreted as shorthand for an `Output` of the appropriate type. The
            only currently supported type is `DirectoryOutput`, where the string
            value given here will be used as the directory path.
        zUnsupported output object %rFN)
isinstancer   OutputstrDirectoryOutput	TypeError_closed)selfoutputs     X/var/www/html/software/conda/lib/python3.11/site-packages/tensorboard/summary/_writer.py__init__zWriter.__init__&   sh     fgn-- 	E!DLL$$ 	E"26::DLL:VCDDD    c                 2    | j         rt          d          d S )NzWriter is already closed)r   RuntimeErrorr   s    r   _check_not_closedzWriter._check_not_closed7   s%    < 	;9:::	; 	;r   c                 `    |                                   | j                                         dS )zFlushes any buffered data.N)r   r   flushr   s    r   r   zWriter.flush;   s.       r   c                 n    |                                   | j                                         d| _        dS )z+Closes the writer and prevents further use.TN)r   r   closer   r   s    r   r   zWriter.close@   s3       r   N)	wall_timedescriptionc                8   |                                   t          t          j        |          d          }t          t          j        |          d          }||nt          j                    }| j                            t          j	        |||||           dS )a  Adds a scalar summary.

        Args:
          tag: string tag used to uniquely identify this time series.
          data: numeric scalar value for this data point. Accepts any value that
            can be converted to a `np.float32` scalar.
          step: integer step value for this data point. Accepts any value that
            can be converted to a `np.int64` scalar.
          wall_time: optional `float` seconds since the Unix epoch, representing
            the real-world timestamp for this data point. Defaults to None in
            which case the current time will be used.
          description: optional string description for this entire time series.
            This should be constant for a given tag; only the first value
            encountered will be used.
        datastepN)plugin_nametagr   r   r   r   )
r   _validate_scalar_shapenpfloat32int64timer   emit_scalarscalars_metadataPLUGIN_NAME)r   r!   r   r   r   r   validated_datavalidated_steps           r   
add_scalarzWriter.add_scalarF   s      	   /
40@0@&II/GG!*!6IIDIKK	  (4# 	! 	
 	
 	
 	
 	
r   )	__name__
__module____qualname____doc__r   r   r   r   r,    r   r   r   r      sz           "; ; ;  
   8< 
 
 
 
 
 
 
r   r   c                 F    | j         dk    rt          d|d|           | S )Nr   zExpected scalar value for z	 but got )ndim
ValueError)ndarraynames     r   r"   r"   d   s8    |qj9=wwG
 
 	
 Nr   )r0   r&   numpyr#   tensorboard.plugins.scalarr   r(   tensorboard.summaryr   r   r"   r1   r   r   <module>r:      s          C C C C C C ' ' ' ' ' 'D
 D
 D
 D
 D
 D
 D
 D
N    r   