o
    ϯi#                  	   @   sL   d dl Z d dlmZ 	dde jdedede jfdd	ZG d
d dejZdS )    N        Fx	drop_probtrainingreturnc                 C   sd   |dks|s| S d| }| j d fd| jd   }|tj|| j| jd }|  | || }|S )z
    Stochastic Depth per sample.

    Args:
        x (tensor): Input tensor.
        drop_prob (float): Probability to apply drop path.
        training (bool): If True, apply drop path to input. Otherwise (tesing), return input.
    r      r   )r   )dtypedevice)shapendimtorchrandr   r	   floor_div)r   r   r   	keep_probr
   maskoutput r   Q/home/ubuntu/.local/lib/python3.10/site-packages/pytorchvideo/layers/drop_path.py	drop_path   s   r   c                       sB   e Zd ZdZddeddf fddZdejdejfd	d
Z  Z	S )DropPathz3
    Drop paths (Stochastic Depth) per sample.
    r   r   r   Nc                    s   t t|   || _dS )zV
        Args:
            drop_prob (float): Probability to apply drop path.
        N)superr   __init__r   )selfr   	__class__r   r   r   #   s   
zDropPath.__init__r   c                 C   s   t || j| jS )z=
        Args:
            x (tensor): Input tensor.
        )r   r   r   )r   r   r   r   r   forward+   s   zDropPath.forward)r   )
__name__
__module____qualname____doc__floatr   r   Tensorr   __classcell__r   r   r   r   r      s    r   )r   F)	r   torch.nnnnr"   r!   boolr   Moduler   r   r   r   r   <module>   s   
