<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def parse_dm_header(f, outdata=None):
 """ This is the start of the DM file. We check for some magic values and then treat the next entry as a tag_root If outdata is supplied, we write instead of read using the dictionary outdata as a source Hopefully parse_dm_header(newf, outdata=parse_dm_header(f)) copies f to newf """

    # filesize is sizeondisk - 16. But we have 8 bytes of zero at the end of
    # the file.
    if outdata is not None:  # this means we're WRITING to the file
        if verbose:
            print("write_dm_header start", f.tell())
        ver, file_size, endianness = 3, -1, 1
        put_into_file(f, "> l l l", ver, file_size, endianness)
        start = f.tell()
        parse_dm_tag_root(f, outdata)
        end = f.tell()
        # start is end of 3 long header. We want to write 2nd long
        f.seek(start - 8)
        # the real file size. We started counting after 12-byte version,fs,end
        # and we need to subtract 16 total:
        put_into_file(f, "> l", end - start + 4)
        f.seek(end)
        enda, endb = 0, 0
        put_into_file(f, "> l l", enda, endb)
        if verbose:
            print("write_dm_header end", f.tell())
    else:
        if verbose:
            print("read_dm_header start", f.tell())
        ver = get_from_file(f, "> l")
        assert ver in [3,4], "Version must be 3 or 4, not %s" % ver
        # argh. why a global?
        global size_type, version
        if ver == 3:
            size_type = 'L'  # may be Q?
            version = 3
        if ver == 4:
            size_type = 'Q'  # may be Q?
            version = 4
        file_size, endianness = get_from_file(f, ">%c l" % size_type)
        assert endianness == 1, "Endianness must be 1, not %s"%endianness
        start = f.tell()
        ret = parse_dm_tag_root(f, outdata)
        end = f.tell()
        # print("fs", file_size, end - start, (end-start)%8)
        # mfm 2013-07-11 the file_size value is not always
        # end-start, sometimes there seems to be an extra 4 bytes,
        # other times not. Let's just ignore it for the moment
        # assert(file_size == end - start)
        enda, endb = get_from_file(f, "> l l")
        assert(enda == endb == 0)
        if verbose:
            print("read_dm_header end", f.tell())
        return ret