§
    ­¸jd  ã                  óF   — d Z ddlmZ ddlmZ ddlZddlmZ 	 	 	 ddd„Z	dS )z'Drop-path / dropout schedule utilities.é    )Úannotations)ÚLiteralN)ÚNDArrayÚstandardÚconstantÚ	drop_rateÚfloatÚepochsÚintÚniter_per_epÚcutoff_epochÚmodeú$Literal['standard', 'early', 'late']ÚscheduleúLiteral['constant', 'linear']ÚreturnúNDArray[np.float64]c                ó<  — |dvrt          d|›�¦  «        ‚|dk     rt          d|› �¦  «        ‚|dk     rt          d|› �¦  «        ‚||z  }|dk    rt          j        || ¦  «        S d|cxk    r|k    sn t          d|› d	|› �¦  «        ‚||z  }t          j        |t          j        ¬
¦  «        }|dk    r@|dvrt          d|›�¦  «        ‚|dk    r| |d|…<   nBt          j        | d|¦  «        |d|…<   n&|dk    r |dk    rt          d|›d�¦  «        ‚| ||d…<   |S )a‰  Build a per-iteration drop-path or dropout rate schedule.

    ``"standard"`` mode: every iteration uses the same ``drop_rate``; ignored ``cutoff_epoch``, ``schedule``.
    ``"early"`` mode: drop rate applies during the first ``cutoff_epoch`` epochs; remaining epochs use zero drop rate.
        optional: schedule ``linear`` decay to zero over the first ``cutoff_epoch`` epochs.
    ``"late"`` mode: the first ``cutoff_epoch`` epochs use zero drop rate; remaining epochs use ``drop_rate``.

    Args:
        drop_rate: Target drop probability.
        epochs: Total number of training epochs.
        niter_per_ep: Number of optimizer steps per epoch.
        cutoff_epoch: Number of epochs in the initial schedule phase. Phases split at cutoff_epoch * niter_per_ep steps.
            Ignored when ``mode`` is ``"standard"``.
        mode: Scheduling strategy: ``"standard"``, ``"early"``, or ``"late"``.
        schedule: Shape of the initial schedule phase in ``"early"`` mode: ``"constant"`` or ``"linear"``.
            Ignored when ``mode`` is ``"standard"``; only ``"constant"`` is accepted for ``"late"`` mode.

    Returns:
        One-dimensional array of length ``epochs * niter_per_ep`` containing the drop rate per iteration.

    Raises:
        ValueError: If ``mode`` is not ``"standard"``, ``"early"``, or ``"late"``.
        ValueError: If ``epochs`` or ``niter_per_ep`` is less than ``1``.
        ValueError: If ``cutoff_epoch`` is not in the range ``[0, epochs]``.
        ValueError: If ``schedule`` is not ``"constant"`` or ``"linear"`` in ``"early"`` mode.
        NotImplementedError: If ``schedule`` is not ``"constant"`` in ``"late"`` mode.
    )r   ÚearlyÚlatez1mode must be 'standard', 'early', or 'late', got é   zepochs must be >= 1, got zniter_per_ep must be >= 1, got r   r   zcutoff_epoch must be in [0, z], but got )Údtyper   )r   Úlinearz-schedule must be 'constant' or 'linear', got r   Nr   z	schedule=zA is not supported for mode='late'; only 'constant' is implemented)Ú
ValueErrorÚnpÚfullÚzerosÚfloat64ÚlinspaceÚNotImplementedError)	r   r
   r   r   r   r   Útotal_itersÚearly_itersÚresults	            úm/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/rfdetr/training/drop_schedule.pyÚdrop_schedulerr%      sŸ  € ðF Ð0Ð0Ð0ÝÐUÈTÐUÐUÑVÔVÐVØ�‚z€zÝÐ=°VÐ=Ð=Ñ>Ô>Ð>Ø�aÒÐÝÐI¸<ÐIÐIÑJÔJÐJØ˜<Ñ'€KØˆzÒÐÝŒw�{ IÑ.Ô.Ð.Ø�Ð&Ð&Ò&Ð& Ò&Ð&Ð&Ð&ÝÐY¸ÐYÐYÈ<ÐYÐYÑZÔZÐZØ Ñ-€KÝŒX�k­¬Ð4Ñ4Ô4€Fàˆw‚€ØÐ1Ð1Ð1ÝÐYÈXÐYÐYÑZÔZÐZØ�zÒ!Ð!Ø#,ˆF�<�K�<Ñ Ð å#%¤;¨y¸!¸[Ñ#IÔ#IˆF�<�K�<Ñ Ð Ø	�ŠˆØ�zÒ!Ð!Ý%Øi˜HÐiÐiÐiñô ð ð  )ˆˆ{ˆ|ˆ|Ñà€Mó    )r   r   r   )r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   )
Ú__doc__Ú
__future__r   Útypingr   Únumpyr   Únumpy.typingr   r%   © r&   r$   ú<module>r-      s}   ðð .Ð -à "Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ð Ð à Ð Ð Ð Ø  Ð  Ð  Ð  Ð  Ð  ð Ø1;Ø.8ð?ð ?ð ?ð ?ð ?ð ?ð ?r&   