<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def dump(cfg, f):
    '''Serialize ``cfg`` as a libconfig-formatted stream into ``f``

    ``cfg`` must be a ``dict`` with ``str`` keys and libconf-supported values
    (numbers, strings, booleans, possibly nested dicts, lists, and tuples).

    ``f`` must be a ``file``-like object with a ``write()`` method.
    '''

    if not isinstance(cfg, dict):
        raise ConfigSerializeError(
                'dump() requires a dict as input, not %r of type %r' %
                (cfg, type(cfg)))

    dump_dict(cfg, f, 0)