def organize_hf_dataset(dataset):
    """
    Organize the dataset with task-based manner

    Return:
        organized_dataset: list, each item is a dict, with the following keys:
            - task_name: str
            - task_query_samples: list of dicts, each dict contains the sample information
    """
    task_dict = {}
    for sample in dataset:
        task_name = sample["task_name"]
        if task_name not in task_dict:
            task_dict[task_name] = []
        task_dict[task_name].append(sample)

    organized_dataset = []
    for task_name, samples in task_dict.items():
        organized_dataset.append({
            "task_name": task_name,
            "task_samples": samples
        })

    return organized_dataset

    Organize the dataset with task-based manner

    Return:
        organized_dataset: list, each item is a dict, with the following keys:
            - task_name: str
            - task_query_samples: list of dicts, each dict contains the sample information
    
vlmeval/dataset/utils/megabench/utils.py