def summarize_variables(variables):
    """Return a string with a table of names and shapes of the given variables."""
    cols = [['Name'], ['Shape']]
    for var in variables:
        shape = var.get_shape().as_list()
        cols[0].append(var.name)
        cols[1].append(str(shape))
    widths = [max(len(x) for x in col) for col in cols]

    lines = ['  '.join(text.ljust(widths[i]) for i, text in enumerate(row)) for row in zip(*cols)]
    lines.insert(1, '  '.join('-' * w for w in widths))
    return '\n'.join(lines)