<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def download(timestamp, dataset, path=None, products=None, levels=None, offset=0):
 """save GFS grib file to DATA_PATH. Args: dataset(function):
 naming convention function. eg. pgrb2 timestamp(datetime):
 ??? path(str):
 if None defaults to DATA_PATH products(list):
 TMP, etc. if None downloads all. layers(list):
 surface, etc. if None downloads all. offset(int):
 should be multiple of 3 """

    if path is None:
        path = DATA_PATH
    closest = timestamp.hour//6*6
    filename = dataset(closest, offset)
    gfs_timestamp = '%s%02d' % (timestamp.strftime('%Y%m%d'), closest)

    url = baseurl(gfs_timestamp, filename)
    index = url + '.idx'
    messages = message_index(index)
    segments = _filter_messages(messages, products, levels)
    dl_path = path + '/%s/' % gfs_timestamp
    _verify_path(dl_path)
    _download_segments(path + filename, url, segments)