def alpha_weight(epoch, T1, T2, af):
    """ calculate value of alpha used in loss based on the epoch
  
    params:
        - epoch: your current epoch
        - T1: threshold for training with only labeled data
        - T2: threshold for training with only unlabeled data
        - af: max alpha value
    """

    if epoch < T1:
        return 0.0

    elif epoch > T2:
        return af

    else:
        return ((epoch - T1) / (T2 - T1)) * af