o
    }oi                     @   s:   d dl mZ 			ddedededed	ee f
d
dZdS )    )List        linear   
num_layersstochastic_depth_drop_probstochastic_depth_modestochastic_depth_start_layerreturnc                    s   d  krdk st d t dd|  kr| ks$t d t ddg| }| |   dkr\|dkrH| fdd	td d D 7 }|S |d
krU|g  7 }|S t d| |S )ar  Computes drop probabilities for stochastic depth regularization technique.
    The first layer is never dropped and the starting layer needs to be greater
    or equal to 1.

    Args:
        num_layers (int): number of layers in the network.
        stochastic_depth_drop_prob (float): if non-zero, will randomly drop
            layers during training. The higher this value, the more often layers
            are dropped. Defaults to 0.0.
        stochastic_depth_mode (str): can be either "linear" or "uniform". If
            set to "uniform", all layers have the same probability of drop. If
            set to "linear", the drop probability grows linearly from 0 for the
            first layer to the desired value for the final layer. Defaults to
            "linear".
        stochastic_depth_start_layer (int): starting layer for stochastic depth.
            All layers before this will never be dropped. Note that drop
            probability will be adjusted accordingly if mode is "linear" when
            start layer is > 1. Defaults to 1.
    Returns:
        List[float]: list of drop probabilities for all layers
    r   g      ?z/stochastic_depth_drop_prob has to be in [0, 1).r   z:stochastic_depth_start_layer has to be in [1, num layers].r   r   c                    s   g | ]}|   qS  r   ).0lLr   r   i/home/ubuntu/.local/lib/python3.10/site-packages/nemo/collections/asr/parts/utils/regularization_utils.py
<listcomp>9   s    z7compute_stochastic_depth_drop_probs.<locals>.<listcomp>uniformzMstochastic_depth_mode has to be one of ["linear", "uniform"]. Current value: )
ValueErrorrange)r   r   r   r	   layer_drop_probsr   r   r   #compute_stochastic_depth_drop_probs   s(   
"r   N)r   r   r   )typingr   intfloatstrr   r   r   r   r   <module>   s   