from typing import List
from typing import Any
from typing import Dict
import collections


def compute_query_statistics(video_annotations: List[Any]) -> Dict[str, int]:
    """
    Compute the total number of visual queries annotated.
    """
    total_queries = 0
    per_split_queries = collections.defaultdict(int)
    for v in video_annotations:
        for c in v["clips"]:
            if c["annotation_complete"]:
                for a in c["annotations"]:
                    for q in a["query_sets"].values():
                        if q["is_valid"]:
                            total_queries += 1
                            per_split_queries[v["split"]] += 1

    query_stats = {"total_queries": total_queries}
    for split, split_queries in per_split_queries.items():
        query_stats[f"{split}_queries"] = split_queries
    return query_stats