def set_hdf5_attributes(dset, attributes):
    """
    Set the attributes for a hdf5 group or dataset
    Args:
        dset: instance of hdf5.File, hdf5.Group of hdf5.DataSet, the hdf5 group or dataset to set
        attributes: dict, dictionary of attributes to set
    Returns:
        The group or attributes with attributes set
    """
    for key in attributes.iterkeys():
        dset.attrs[key] = attributes[key]

    return dset