def load_metadata(filename):
    """Load and parse the metadata file for a given dataset.

    Args:
        filename: path to the metadata file

    Returns:
        A dictionnary of the metadata values
    """
    metadata = {}
    with open(filename, 'r') as f:
        for line in f.read().splitlines():
            key, values = line.split('\t', 1)
            if key in ['data_classes', 'feature_keys']:
                metadata[key] = values.split(',')
            elif key.endswith('tfrecords') or key == 'image_folder':
                metadata[key] = values
            else:
                metadata[key] = int(values)
        return metadata