def _cal_macl_loss_original(
    pos: Tensor, neg: Tensor, tau_0: float, alpha: float, A0: float
) -> Tensor:
    """The original implementation of the MACL loss.

    See: https://github.com/chenhaoxing/MACL/blob/main/macl.py
    Note that the original implementation is not numerically stable, so the error bar here is 1e-6.

    Args:
        pos:
            The positive cosine similarities.
        neg:
            The negative cosine similarities.
        tau_0:
            The initial temperature. Must be greater than 0.
        alpha:
            The alpha parameter. Must be in the range [0, 1].
        A0:
            The initial value of A. Must be in the range [0, 1].

    Returns:
        The loss value.
    """

    A = torch.mean(pos.detach())
    tau = tau_0 * (1.0 + alpha * (A - A0))

    logits = torch.cat([pos, neg], dim=1) / tau
    P = torch.softmax(logits, dim=1)[:, 0]

    # reweighting and loss computation
    V = 1.0 / (1.0 - P)
    loss: Tensor = -V.detach() * torch.log(P)

    return loss.mean()
The original implementation of the MACL loss.

    See: https://github.com/chenhaoxing/MACL/blob/main/macl.py
    Note that the original implementation is not numerically stable, so the error bar here is 1e-6.

    Args:
        pos:
            The positive cosine similarities.
        neg:
            The negative cosine similarities.
        tau_0:
            The initial temperature. Must be greater than 0.
        alpha:
            The alpha parameter. Must be in the range [0, 1].
        A0:
            The initial value of A. Must be in the range [0, 1].

    Returns:
        The loss value.
    
tests/loss/test_macl_loss.py