def vec_to_text_line(label, vec):
    """
    Output a labeled vector as a line in a fastText-style text format.
    """
    cells = [label] + ['%4.4f' % val for val in vec]
    return ' '.join(cells)