<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_data(data, type, **kwargs):
 """ Return an OSM networkx graph from the input OSM data Parameters data : string type : string ('xml' or 'pbf') """

    suffixes = {
        'xml': '.osm',
        'pbf': '.pbf',
    }
    try:
        suffix = suffixes[type]
    except KeyError:
        raise ValueError('Unknown data type "%s"' % type)

    fd, filename = tempfile.mkstemp(suffix=suffix)
    try:
        os.write(fd, data)
        os.close(fd)
        return parse_file(filename, **kwargs)
    finally:
        os.remove(filename)