'Computes the log probability of a sequence of values.
Flattens the time dimension.
Args:
sequences: A batch of sequences to compute the log probabilities of,
sized `[batch_size, max(lengths), num_dims]`.
lengths: The length of each sequence, sized `[batch_size]` or None if
all are equal.
Returns:
log_prob: The log probability of each sequence value, sized
`[sum(lengths), 1]`.
cond_prob: The conditional probabilities at each non-padded value for
every batch, sized `[sum(lengths), num_dims]`.'

def log_prob(self, sequences, lengths=None):

    assert (self._num_dims == sequences.shape[2].value)
    inputs = sequences[:, 0:(-1), :]
    inputs = tf.pad(inputs, [[0, 0], [1, 0], [0, 0]])
    state = self._get_state(inputs, lengths=lengths)
    labels_flat = magenta.common.flatten_maybe_padded_sequences(sequences, lengths)
    return self._nade.log_prob(labels_flat, state.b_enc, state.b_dec)
