<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write_fmt(fp, fmt, *args):
 """ Writes data to ``fp`` according to ``fmt``. """

    fmt = str(">" + fmt)
    fmt_size = struct.calcsize(fmt)
    written = write_bytes(fp, struct.pack(fmt, *args))
    assert written == fmt_size, 'written=%d, expected=%d' % (
        written, fmt_size
    )
    return written