o
    }oi
                     @   sB   d dl mZ d dlZdd Zdd Zddeej defd	d
ZdS )    )IterableNc                   C   s   t j ot j dkS )N   )torchdistributedis_initializedget_world_size r   r   `/home/ubuntu/.local/lib/python3.10/site-packages/nemo/collections/tts/parts/utils/distributed.py_is_distributed*   s   r
   c                 C   s   t | p	t | S )N)r   is_floating_point
is_complex)tensorr   r   r	   _is_complex_or_float.   s   r   tensorssrcc                 C   sZ   t  sdS dd | D } g }| D ]}tjj|j|dd}|| q|D ]}|  q$dS )z
    Broadcast the tensors from the given parameters to all workers.
    This can be used to ensure that all workers have the same model to start with.
    Nc                 S   s   g | ]}t |r|qS r   )r   ).0r   r   r   r	   
<listcomp>:   s    z%broadcast_tensors.<locals>.<listcomp>T)r   async_op)r
   r   r   	broadcastdataappendwait)r   r   handlesr   handler   r   r	   broadcast_tensors2   s   
r   )r   )typingr   r   r
   r   Tensorintr   r   r   r   r	   <module>   s
   $