
    ¯wg                     N    d dl  d dlmZ d dl mZ erd dlmZ dZ G d d      Zy)	    )*)TYPE_CHECKING)_WaitCounter)SummaryWriterztorch.monitor.Statc                   (    e Zd ZdZddZdeddfdZy)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))
    returnNc                     || _         y)z=
        Constructs the ``TensorboardEventHandler``.
        N)_writer)selfwriters     [/home/mcse/projects/flask/flask-venv/lib/python3.12/site-packages/torch/monitor/__init__.py__init__z TensorboardEventHandler.__init__   s         eventc                     |j                   t        k(  rY|j                  j                         D ];  \  }}| j                  j                  |||j                  j                                = y y )N)walltime)name
STAT_EVENTdataitemsr   
add_scalar	timestamp)r   r   kvs       r   __call__z TensorboardEventHandler.__call__#   s[    ::#

((* T1''1u7P7P7R'ST $r   )r   r   r	   N)__name__
__module____qualname____doc__r   Eventr    r   r   r   r      s"    Te T Tr   r   N)torch._C._monitortypingr   r   torch.utils.tensorboardr   r   r   r"   r   r   <module>r&      s'       *5 "
T Tr   