def METHOD_NAME(table, trntab):
    """Checking the balance between different training classes."""
    msg = _("Checking the balance between different training classes.")
    msgr = get_msgr()
    msgr.message(msg)
    chk_balance = (
        "SELECT class, count(*) as num_of_segments "
        "FROM {tname} "
        "GROUP BY class ORDER BY num_of_segments;"
    )
    res = table.execute(chk_balance.format(tname=table.name))
    cl_sql = "SELECT cat, class FROM {tname} ORDER BY cat;"
    clss = dict(trntab.execute(cl_sql.format(tname=trntab.name)))
    for cls, num in res.fetchall():
        clname = clss.get(cls, str(cls))
        msgr.message(
            "    - %s (%d): %d"
            % (clname if clname else repr(clname), cls if cls else 0, num)
        )