(namespace, var_name, training, polyak_decay)
utility for retrieving polyak averaged params
        Update average
utility for retrieving polyak averaged params
        Update average
utility for retrieving polyak averaged params Update average
def get_var_maybe_avg(namespace, var_name, training, polyak_decay):
    """ utility for retrieving polyak averaged params
        Update average
    """
    v = getattr(namespace, var_name)
    v_avg = getattr(namespace, var_name + '_avg')
    v_avg -= (1 - polyak_decay) * (v_avg - v.data)

    if training:
        return v
    else:
        return v_avg
def get_var_maybe_avg ( namespace , var_name , training , polyak_decay ) : v = getattr ( namespace , var_name ) v_avg = getattr ( namespace , var_name + '_avg' ) v_avg -= ( 1 - polyak_decay ) * ( v_avg - v . data ) if training : return v else : return v_avg