o
    }oi                     @   sT   d dl Z d dlZd dlmZ d dlmZ ddddddd	Zd
ededefddZdS )    N)List)loggingi   i }  i  i  iHq  )gpt3llama2llama3nemotronbertmixtralpathsummary_namereturnc                    s   ddl m} t  d}|j fddd t|dks&tj|d s*td|d }z"|	|}|
  ||}dd	 |D }t| d
|  W |S  ty`   t| d| w )aa  
    Reads a TensorBoard Events file from the input path, and returns the
    summary specified.

    Args:
        path: str, path to the dir where the events file is located.
        summary_name: str, name of the summary to read from the TB logs.
    Returns:
        summary_list: list, the values in the read summary list, formatted as a list.
    r   )event_accumulatorz/events*tfevents*c                    s   t jt j | S )N)osr
   getmtimejoin)xr
    d/home/ubuntu/.local/lib/python3.10/site-packages/nemo/collections/common/parts/perf_metrics_utils.py<lambda>.   s    zread_tb_log.<locals>.<lambda>)keyzMissing TensorBoard log file.c                 S   s   g | ]}t |jd qS )   )roundvalue).0r   r   r   r   
<listcomp>7   s    zread_tb_log.<locals>.<listcomp>z: z not found in )$tensorboard.backend.event_processingr   globsortlenr   r
   isfileFileNotFoundErrorEventAccumulatorReloadScalarsr   infoKeyError)r
   r   r   filesevents_fileeasummarysummary_listr   r   r   read_tb_log    s    

r,   )	r   r   typingr   
nemo.utilsr   LLM_VOCAB_SIZE_MAPstrr,   r   r   r   r   <module>   s   
