code: def annotate_eval_result_plots(
      model_card: model_card_module.ModelCard,
      eval_result: tfma.EvalResult,
  ) -> None:
      """Annotates visualizations for every metric in eval_result.
  
      This function generates barcharts for sliced metrics, encoded as base64 text
      strings, and appends them to
      model_card.quantitative_analysis.graphics.collection.
  
      Args:
        model_card: The model card object.
        eval_result: A `tfma.EvalResult`.
      """
  
      # get all metric and slice names
      metrics = set()
      slices_keys = set()
      for slicing_metric in eval_result.slicing_metrics:
          slices_key, _ = graphics.stringify_slice_key(
              slicing_metric[0]
          )
          if slices_key != "Overall":
              slices_keys.add(slices_key)
          for output_name in slicing_metric[1]:
              for sub_key in slicing_metric[1][output_name]:
                  metrics.update(
                      slicing_metric[1][output_name][sub_key].keys()
                  )
  
      # generate barcharts based on metrics and slices
      graphs = []
      if not slices_keys:
          slices_keys.add("")
      for metric in metrics:
          for slices_key in slices_keys:
              graph = _extract_graph_data_from_slicing_metrics(
                  eval_result.slicing_metrics, metric, slices_key
              )
              graph = graphics.draw_histogram(graph)
              if graph is not None:
                  graphs.append(graph)
  
      # annotate model_card with generated graphs
      model_card.quantitative_analysis.graphics.collection.extend(
          [
              model_card_module.Graphic(
                  name=graph.name, image=graph.base64str
              )
              for graph in graphs
          ]
      )
  
file_path: model-card-toolkit/model_card_toolkit/utils/tf_graphics.py
imports: import logging
  from typing import Optional, Sequence, Union
  import tensorflow_model_analysis
  from tensorflow_metadata.proto.v0 import statistics_pb2
  from model_card_toolkit import model_card
  from model_card_toolkit.utils import graphics
label_desc: Use image node_id 2 for calling a global function with example usage: annotate_eval_result_plots(model_card, eval_result) without return types