import tensorflow as tf

    y_h_diff = y[:, 1:] - y[:, :-1]
    y_w_diff = y[:, :, 1:] - y[:, :, :-1]
    h_diff = tf.abs(tf.abs(x_h_diff) - tf.abs(y_h_diff))
    w_diff = tf.abs(tf.abs(x_w_diff) - tf.abs(y_w_diff))
    return h_diff + tf.transpose(w_diff)

