o
    }o™ik  ã                   @   s   d dl Z dd„ ZdS )é    Nc                 C   sB   | j d }t |dd¡ | j¡d|  }t |¡ ¡ }| | } | S )zÞ
    Function to perform random dropout for embeddings.
    When we drop embeddings, we zero them out.
    Args:
        embeddings (tensor): Input embeddings
        drop_rate (float): Rate of dropping the embedding.
    r   é   )ÚshapeÚtorchÚonesÚtoÚdtypeÚ	bernoulliÚcuda)Ú
embeddingsÚ	drop_rateÚnsamplesÚ	zero_flag© r   úb/home/ubuntu/.local/lib/python3.10/site-packages/nemo/collections/multimodal/parts/imagen/utils.pyÚrandom_dropout   s
   
r   )r   r   r   r   r   r   Ú<module>   s   