
    RЦi                          S r SSKrSS jrS rg)zBBatch size decay and retry helpers.

Copyright 2022 Ross Wightman
    Nc                     U S::  a  g[        S[        R                  " U S-
  5      [        R                  " S5      -  -  5      n[        X1-  S5      nX0U-
  S-
  U-  U-  -   n U(       a  U S-  (       a  U S-  n U $ )aP  power of two batch-size decay with intra steps

Decay by stepping between powers of 2:
* determine power-of-2 floor of current batch size (base batch size)
* divide above value by num_intra_steps to determine step size
* floor batch_size to nearest multiple of step_size (from base batch size)
Examples:
 num_steps == 4 --> 64, 56, 48, 40, 32, 28, 24, 20, 16, 14, 12, 10, 8, 7, 6, 5, 4, 3, 2, 1
 num_steps (no_odd=True) == 4 --> 64, 56, 48, 40, 32, 28, 24, 20, 16, 14, 12, 10, 8, 6, 4, 2
 num_steps == 2 --> 64, 48, 32, 24, 16, 12, 8, 6, 4, 3, 2, 1
 num_steps == 1 --> 64, 32, 16, 8, 4, 2, 1
   r      )intmathlogmax)
batch_sizenum_intra_stepsno_oddbase_batch_size	step_sizes        U/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/timm/utils/decay_batch.pydecay_batch_stepr      s{     Q!a 8DHHQK GHIOO6:I /%AA%E)$SW`#``J*q.a
    c                 @    U R                  5       n SU ;   a  gSU ;   a  gg)z^check failure error string for conditions where batch decay retry should not be attempted
    zrequired rankFillegalT)lower)	error_strs    r   check_batch_size_retryr       s+     !I)# Ir   )r   F)__doc__r   r   r    r   r   <module>r      s    0r   