Ë
    þÍ: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                  j                  d«        G d„ dej                  «      Zy)é    N)ÚnnÚTensoré   )Ú_log_api_usage_onceÚinputÚpÚmodeÚtrainingÚreturnc                 ó,  — t         j                  j                  «       s-t         j                  j                  «       st	        t
        «       |dk  s|dkD  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                  ¬	«      }|j                  |«      }|dkD  r|j                  |«       | |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          úu/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/torchvision/ops/stochastic_depth.pyr   r      s  € ô$ �9‰9×!Ñ!Ô#¬E¯I©I×,@Ñ,@Ô,BÜÔ,Ô-Øˆ3‚w�!�c’'ÜÐOÐPQÈsÐSÓTÐTØÐ#Ñ#ÜÐKÈDÈ6ÐRÓSÐSÙ�q˜C’xØˆà˜!‘G€MØˆu‚}Ø—‘˜A‘Ð 1 #¨¯©°a©Ñ"8Ñ8‰àˆs�U—Z‘ZÑˆÜ�K‰K˜ E§K¡K¸¿¹Ô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         ‰| �  «        t        | «       || _        || _        y ©N)ÚsuperÚ__init__r   r   r	   )Úselfr   r	   Ú	__class__s      €r    r'   zStochasticDepth.__init__7   s$   ø€ Ü‰ÑÔÜ˜DÔ!ØˆŒØˆ�	r!   r   c                 óZ   — t        || j                  | j                  | j                  «      S r%   )r   r   r	   r
   )r(   r   s     r    ÚforwardzStochasticDepth.forward=   s   € Ü  t§v¡v¨t¯y©y¸$¿-¹-ÓHÐHr!   c                 ól   — | j                   j                  › d| j                  › d| j                  › d�}|S )Nz(p=z, mode=ú))r)   Ú__name__r   r	   )r(   Úss     r    Ú__repr__zStochasticDepth.__repr__@   s2   € Ø�~‰~×&Ñ&Ð' s¨4¯6©6¨(°'¸$¿)¹)¸ÀAÐFˆØˆr!   )r.   Ú
__module__Ú__qualname__Ú__doc__ÚfloatÚstrr'   r   r+   r0   Ú__classcell__)r)   s   @r    r#   r#   2   sD   ø„ ñð˜%ð  sð ¨tõ ðI˜Vð 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‘iõ r!   