def _calculate_pycls_momentum(
    alpha: float, total_batch_size: int, max_epoch: int, update_period: int
):
    """pycls style momentum calculation which uses a relative model_ema to decouple momentum with
    other training hyper-parameters e.g.

        * training epochs
        * interval to update ema
        * batch sizes

    Usually the alpha is a tiny positive floating number, e.g. 1e-4 or 1e-5,
    with ``max_epoch=100``, ``total_batch_size=1024`` and ``update_period=32``, the ema
    momentum should be 0.996723175, which has roughly same behavior to the default setting.
    i.e. ``momentum=0.9999`` together with ``update_period=1``
    """
    return max(0, 1 - alpha * (total_batch_size / max_epoch * update_period))