§
    ù²Åjþ  ã                   óª   — d dl Z d dlZ d dl mZmZ ddlmZ ddededed	ed
ef
d„Z	e j
                             d¦  «          G d„ dej        ¦  «        ZdS )é    N)ÚnnÚTensoré   )Ú_log_api_usage_onceTÚinputÚpÚmodeÚtrainingÚreturnc                 ó2  — t           j                             ¦   «         s2t           j                             ¦   «         st	          t
          ¦  «         |dk     s|dk    rt          d|› �¦  «        ‚|dvrt          d|› �¦  «        ‚|r|dk    r| S d|z
  }|dk    r| j        d         gdg| j        dz
  z  z   }ndg| j        z  }t          j	        || j
        | j        ¬	¦  «        }|                     |¦  «        }|dk    r|                     |¦  «         | |z  S )
aö  
    Implements the Stochastic Depth from `"Deep Networks with Stochastic Depth"
    <https://arxiv.org/abs/1603.09382>`_ used for randomly dropping residual
    branches of residual architectures.

    Args:
        input (Tensor[N, ...]): The input tensor or arbitrary dimensions with the first one
                    being its batch i.e. a batch with ``N`` rows.
        p (float): probability of the input to be zeroed.
        mode (str): ``"batch"`` or ``"row"``.
                    ``"batch"`` randomly zeroes the entire input, ``"row"`` zeroes
                    randomly selected rows from the batch.
        training: apply stochastic depth if is ``True``. Default: ``True``

    Returns:
        Tensor[N, ...]: The randomly zeroed tensor.
    g        g      ð?z4drop probability has to be between 0 and 1, but got )ÚbatchÚrowz0mode has to be either 'batch' or 'row', but got r   r   é   )ÚdtypeÚdevice)ÚtorchÚjitÚis_scriptingÚ
is_tracingr   Ústochastic_depthÚ
ValueErrorÚshapeÚndimÚemptyr   r   Ú
bernoulli_Údiv_)r   r   r	   r
   Úsurvival_rateÚsizeÚnoises          úQC:\Projects\Historical\venv\Lib\site-packages\torchvision/ops/stochastic_depth.pyr   r      s5  € õ$ Œ9×!Ò!Ñ#Ô#ð .­E¬I×,@Ò,@Ñ,BÔ,Bð .ÝÕ,Ñ-Ô-Ð-Øˆ3‚w€w�!�c’'�'ÝÐSÐPQÐSÐSÑTÔTÐTØÐ#Ð#Ð#ÝÐRÈDÐRÐRÑSÔSÐSØð �q˜C’x�xØˆà˜!‘G€MØˆu‚}€}Ø”˜A”Ð 1 #¨¬°a©Ñ"8Ñ8ˆˆàˆs�U”ZÑˆÝŒK˜ E¤K¸¼ÐEÑEÔE€EØ×Ò˜]Ñ+Ô+€EØ�sÒÐØ�
Š
�=Ñ!Ô!Ð!Ø�5‰=Ðó    r   c                   óL   ‡ — e Zd ZdZdededdfˆ fd„Zdedefd„Zdefd	„Z	ˆ xZ
S )
ÚStochasticDepthz'
    See :func:`stochastic_depth`.
    r   r	   r   Nc                 ó‚   •— t          ¦   «                              ¦   «          t          | ¦  «         || _        || _        d S ©N)ÚsuperÚ__init__r   r   r	   )Úselfr   r	   Ú	__class__s      €r    r'   zStochasticDepth.__init__7   s9   ø€ Ý‰Œ×ÒÑÔÐÝ˜DÑ!Ô!Ð!ØˆŒØˆŒ	ˆ	ˆ	r!   r   c                 óD   — t          || j        | j        | j        ¦  «        S r%   )r   r   r	   r
   )r(   r   s     r    ÚforwardzStochasticDepth.forward=   s   € Ý  t¤v¨t¬y¸$¼-ÑHÔHÐHr!   c                 óD   — | j         j        › d| j        › d| j        › d�}|S )Nz(p=z, mode=ú))r)   Ú__name__r   r	   )r(   Úss     r    Ú__repr__zStochasticDepth.__repr__@   s.   € ØŒ~Ô&ÐFÐF¨4¬6ÐFÐF¸$¼)ÐFÐFÐFˆØˆr!   )r.   Ú
__module__Ú__qualname__Ú__doc__ÚfloatÚstrr'   r   r+   r0   Ú__classcell__)r)   s   @r    r#   r#   2   sŸ   ø€ € € € € ðð ð˜%ð  sð ¨tð ð ð ð ð ð ðI˜Vð I¨ð Ið Ið Ið Ið˜#ð ð ð ð ð ð ð ð r!   r#   )T)r   Útorch.fxr   r   Úutilsr   r4   r5   Úboolr   ÚfxÚwrapÚModuler#   © r!   r    ú<module>r>      sÌ   ðØ €€€Ø €€€Ø Ð Ð Ð Ð Ð Ð Ð à 'Ð 'Ð 'Ð 'Ð 'Ð 'ð$ð $˜Fð $ uð $°Cð $À4ð $ÐSYð $ð $ð $ð $ðN „‡‚Ð Ñ !Ô !Ð !ðð ð ð ð �b”iñ ô ð ð ð r!   