o

    h;                     @   s4   d dl Z d dlmZ dddZG dd dejZdS )	    N        Fc                 C   s`   |dks|s| S d| }| j d fd| jd   }|tj|| j| jd }| ||  }|S )a  Drop paths (Stochastic Depth) per sample (when applied in main path of
    residual blocks).

    We follow the implementation
    https://github.com/rwightman/pytorch-image-models/blob/a2727c1bf78ba0d7b5727f5f95e37fb7f8866b1f/timm/models/layers/drop.py  # noqa: E501
    r      r   )r   )dtypedevice)shapendimtorchrandr   r   divfloor)x	drop_probtraining	keep_probr   
random_tensoroutput r   3/root/Awesome-Backbones/configs/common/drop_path.py	drop_path   s   
r   c                       s*   e Zd ZdZd fdd	Zdd Z  ZS )DropPathaj  Drop paths (Stochastic Depth) per sample  (when applied in main path of
    residual blocks).

    We follow the implementation
    https://github.com/rwightman/pytorch-image-models/blob/a2727c1bf78ba0d7b5727f5f95e37fb7f8866b1f/timm/models/layers/drop.py  # noqa: E501

    Args:
        drop_prob (float): Probability of the path to be zeroed. Default: 0.1
    皙?c                    s   t t|   || _d S N)superr   __init__r
   )selfr
   	__class__r   r   r   !   s   
zDropPath.__init__c                 C   s   t || j| jS r   )r   r
   r   )r   r   r   r   r   forward%   s   zDropPath.forward)r   )__name__
__module____qualname____doc__r   r   
__classcell__r   r   r   r   r      s    
r   )r   F)r   torch.nnnnr   Moduler   r   r   r   r   <module>   s    
