U
    Mh                     @   s:   d dl T d dlmZ er$d dlmZ dZG dd dZdS )    )*)TYPE_CHECKING)SummaryWriterztorch.monitor.Statc                   @   s0   e Zd ZdZdddddZedddd	ZdS )
TensorboardEventHandlera]  
    TensorboardEventHandler is an event handler that will write known events to
    the provided SummaryWriter.

    This currently only supports ``torch.monitor.Stat`` events which are logged
    as scalars.

    Example:
        >>> # xdoctest: +REQUIRES(env:TORCH_DOCTEST_MONITOR)
        >>> # xdoctest: +REQUIRES(module:tensorboard)
        >>> from torch.utils.tensorboard import SummaryWriter
        >>> from torch.monitor import TensorboardEventHandler, register_event_handler
        >>> writer = SummaryWriter("log_dir")
        >>> register_event_handler(TensorboardEventHandler(writer))
    r   N)writerreturnc                 C   s
   || _ dS )z=
        Constructs the ``TensorboardEventHandler``.
        N)_writer)selfr    r
   H/var/www/html/venv/lib/python3.8/site-packages/torch/monitor/__init__.py__init__   s    z TensorboardEventHandler.__init__)eventr   c                 C   s:   |j tkr6|j D ] \}}| jj|||j d qd S )N)Zwalltime)name
STAT_EVENTdataitemsr   Z
add_scalar	timestamp)r	   r   kvr
   r
   r   __call__"   s    
z TensorboardEventHandler.__call__)__name__
__module____qualname____doc__r   Eventr   r
   r
   r
   r   r      s   r   N)Ztorch._C._monitortypingr   Ztorch.utils.tensorboardr   r   r   r
   r
   r
   r   <module>   s
   