'Condition the input on the encoding.
Args:
x: The [mb, length, channels] float tensor input.
encoding: The [mb, encoding_length, channels] float tensor encoding.
Returns:
The output after broadcasting the encoding to x\'s shape and adding them.'

@staticmethod
def _condition(x, encoding):

    (mb, length, channels) = x.get_shape().as_list()
    (enc_mb, enc_length, enc_channels) = encoding.get_shape().as_list()
    assert (enc_mb == mb)
    assert (enc_channels == channels)
    encoding = tf.reshape(encoding, [mb, enc_length, 1, channels])
    x = tf.reshape(x, [mb, enc_length, (-1), channels])
    x += encoding
    x = tf.reshape(x, [mb, length, channels])
    x.set_shape([mb, length, channels])
    return x
