code: def weight(w, sparsity):
    
    w_shape = common_layers.shape_list(w)
    k = int(np.prod(w_shape[:-1]))
    count = tf.to_int32(k * sparsity)
    mask = common_layers.weight_targeting(w, count)
    return (1 - mask) * w
docs: Weight-level magnitude pruning.