def readable_outputs(seq, reverse_vocab, end_symbol_id=None):
    """ Convert a sequence of output indices to readable string outputs
    from a given (reverse) vocab """
    if end_symbol_id is None:
        return ' '.join([reverse_vocab[s] for s in seq])
    else:
        outputs = []
        for s in seq:
            outputs.append(reverse_vocab[s])
            if s == end_symbol_id:
                break
        return ' '.join(outputs)