from typing import Dict
from typing import Any


def remove_unused_tasks(
    toml_dict: Dict[str, Dict[str, Any]], task: str
) -> Dict[str, Dict[str, Any]]:
    """
    Remove options depending on other tasks than task

    Args:
        toml_dict: dictionary of options as written in a TOML file.
        task: task which will be learnt by the network.

    Returns:
        updated TOML dictionary.
    """
    task_list = ["classification", "regression", "reconstruction"]

    if task not in task_list:
        raise ValueError(
            f"Invalid value for network_task {task}. "
            f"Please task choose in {task_list}."
        )
    task_list.remove(task)

    # Delete all sections related to other tasks
    for other_task in task_list:
        if other_task.capitalize() in toml_dict:
            del toml_dict[other_task.capitalize()]

    return toml_dict