a
    h5                     @   s  U d dl Z d dlZd dlmZmZmZ d dlmZ d dlZd dl	m
Z d dlmZ d dlmZ g Zee ed< dZefeejdd	d
Zefeeejef dddZe aeeef dddZedZedZeeef eeef dddZeeef eeef dddZ dS )    N)AnyCallableTypeVar)	ParamSpec)_log_handlers)_WaitCounter__all__default)destinationreturnc                 C   sP   t | \}}td| }|tj td}|| d|_|| |S )Nzc10d-za%(asctime)s %(filename)s:%(lineno)s %(levelname)s p:%(processName)s t:%(threadName)s: %(message)sF)	_get_logging_handlerlogging	getLoggersetLevelDEBUG	FormattersetFormatter	propagate
addHandler)r
   Zlogging_handlerlog_handler_namelogger	formatter r   K/var/www/auris/lib/python3.9/site-packages/torch/distributed/c10d_logger.py_get_or_create_logger   s    

r   c                 C   s$   t |  }t|j d|  }||fS )N-)r   type__name__)r
   Zlog_handlerr   r   r   r   r   '   s    r   )r   c              	   O   s   t  r|dp|d}|  t |d t | t   t | t   t | d}|d dkrtjj	
 }ddd	 |D |d
< n
d|  i}|S )NgroupZprocess_groupZpg)	func_nameZpg_namebackendZ
world_sizeZ
group_sizeZglobal_rankZ
local_rankr    nccl.c                 s   s   | ]}t |V  qd S )N)str).0vr   r   r   	<genexpr>A       z _get_msg_dict.<locals>.<genexpr>nccl_versionr   )distZis_initializedgetZ_get_process_group_nameget_backendZget_world_sizeZget_ranktorchZcudar!   versionjoin)r   argskwargsr   msg_dictr(   r   r   r   _get_msg_dict3   s     


	r2   _T_P)funcr   c                    s(   t  tjtjtd fdd}|S )Nr/   r0   r   c               
      sh   z | i |W S  t yb } z:t jg| R i |}| |d< t|  W Y d }~n
d }~0 0 d S )Nerror)	Exceptionr2   r   _c10d_loggerdebug)r/   r0   r7   r1   r5   r   r   wrapperN   s    

z"_exception_logger.<locals>.wrapper	functoolswrapsr4   r/   r0   r3   r5   r<   r   r;   r   _exception_loggerM   s    	rA   c                    s(   t  tjtjtd fdd}|S )Nr6   c                     sF   t d j    | i |}W d    n1 s80    Y  |S )Nzpytorch.wait_counter.c10d.)r   r   Zguard)r/   r0   Zfunc_returnr;   r   r   r<   \   s    ,z_time_logger.<locals>.wrapperr=   r@   r   r;   r   _time_logger[   s    rB   )!r>   r   typingr   r   r   Ztyping_extensionsr   r,   Ztorch.distributedZdistributedr)   Z"torch.distributed.logging_handlersr   Ztorch.monitorr   r   listr#   __annotations__Z_DEFAULT_DESTINATIONLoggerr   tupleHandlerr   r9   dictr2   r3   r4   rA   rB   r   r   r   r   <module>
   s*   
	 