def smooth_l1_distance(labels, preds, delta=1.0):
    """
    Compute the smooth l1_distance.

    :param labels: A float tensor of shape [batch_size, ..., X] representing the labels.
    :param preds: A float tensor of shape [batch_size, ..., X] representing the predictions.
    :param delta: `float`, the point where the huber loss function changes from a quadratic to linear.
    :return: A float tensor of shape [batch_size, ...] representing the smooth l1 distance.
    """
    with tf.variable_scope("smooth_l1"):
        return tf.reduce_sum(tf.losses.huber_loss(
            labels=labels,
            predictions=preds,
            delta=delta,
            loss_collection=None,
            reduction=tf.losses.Reduction.NONE
        ), axis=-1)
Compute the smooth l1_distance.

    :param labels: A float tensor of shape [batch_size, ..., X] representing the labels.
    :param preds: A float tensor of shape [batch_size, ..., X] representing the predictions.
    :param delta: `float`, the point where the huber loss function changes from a quadratic to linear.
    :return: A float tensor of shape [batch_size, ...] representing the smooth l1 distance.