def harmonic_mean_reward_fn(env, top1, top5, vloss, total_macs):
    """This reward is based on the idea of weighted harmonic mean

    Balance compute and accuracy provided a beta value that weighs the two components.
    See: https://en.wikipedia.org/wiki/F1_score
    """
    beta = 1
    # beta = 0.75  # How much to favor accuracy
    macs_normalized = total_macs / env.dense_model_macs
    reward = (1 + beta**2) * top1 / 100 * macs_normalized / (
        beta**2 * macs_normalized + top1 / 100
    )
    return reward