
    h                         S SK r S SKr S SK JrJr  SSKJr  SS\S\S\S\S	\4
S
 jjr	\ R                  R                  S5         " S S\R                  5      rg)    N)nnTensor   )_log_api_usage_onceinputpmodetrainingreturnc                 P   [         R                  R                  5       (       d2  [         R                  R                  5       (       d  [	        [
        5        US:  d  US:  a  [        SU 35      eUS;  a  [        SU 35      eU(       a  US:X  a  U $ SU-
  nUS:X  a%  U R                  S   /S/U R                  S-
  -  -   nOS/U R                  -  n[         R                  " XPR                  U R                  S	9nUR                  U5      nUS:  a  UR                  U5        X-  $ )
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          X/var/www/auris/envauris/lib/python3.13/site-packages/torchvision/ops/stochastic_depth.pyr   r      s   $ 99!!##EII,@,@,B,B,-3w!c'OPQsSTT##KD6RSSqCx!GMu}A1#a"88sUZZKKKKEE]+Es

=!=    r   c                   \   ^  \ rS rSrSrS\S\SS4U 4S jjrS\S\4S	 jr	S\4S
 jr
SrU =r$ )StochasticDepth2   z
See :func:`stochastic_depth`.
r   r	   r   Nc                 P   > [         TU ]  5         [        U 5        Xl        X l        g N)super__init__r   r   r	   )selfr   r	   	__class__s      r    r(   StochasticDepth.__init__7   s     D!	r!   r   c                 X    [        XR                  U R                  U R                  5      $ r&   )r   r   r	   r
   )r)   r   s     r    forwardStochasticDepth.forward=   s    vvtyy$--HHr!   c                 l    U R                   R                   SU R                   SU R                   S3nU$ )Nz(p=z, mode=))r*   __name__r   r	   )r)   ss     r    __repr__StochasticDepth.__repr__@   s2    ~~&&'s466('$))AFr!   )r	   r   )r1   
__module____qualname____firstlineno____doc__floatstrr(   r   r-   r3   __static_attributes____classcell__)r*   s   @r    r#   r#   2   sI    % s t IV I I#  r!   r#   )T)r   torch.fxr   r   utilsr   r9   r:   boolr   fxwrapModuler#    r!   r    <module>rD      s^       '$F $u $C $4 $SY $N   !bii r!   