code: def rounding_accuracy(predictions,
                        labels,
                        weights_fn=common_layers.weights_nonzero):
    
    outputs = tf.squeeze(tf.to_int32(predictions))
    labels = tf.squeeze(labels)
    weights = weights_fn(labels)
    labels = tf.to_int32(labels)
    return tf.to_float(tf.equal(outputs, labels)), weights
docs: Rounding accuracy for L1/L2 losses: round down the predictions to ints.