def calculate_error_by_annotation(graph: BELGraph, annotation: str) -> Mapping[str, List[str]]:
results = defaultdict(list)<EOL>for _, exc, ctx in graph.warnings:<EOL><INDENT>if not ctx or not edge_has_annotation(ctx, annotation):<EOL><INDENT>continue<EOL><DEDENT>values = ctx[ANNOTATIONS][annotation]<EOL>if isinstance(values, str):<EOL><INDENT>results[values].append(exc.__class__.__name__)<EOL><DEDENT>elif isinstance(values, Iterable):<EOL><INDENT>for value in values:<EOL><INDENT>results[value].append(exc.__class__.__name__)<EOL><DEDENT><DEDENT><DEDENT>return dict(results)<EOL>
Group the graph by a given annotation and builds lists of errors for each.

    :return: A dictionary of {annotation value: list of errors}