code: def create_relative_bar_plot(
      value: List[Tuple[int, int]]
  ) -> plt.Figure:
      """
      Counts the categories in value and prepares a relative bar plot of these.
  
      :param value: List of Tuples of (action, action_dim)
      :return: plt.figure that contains a bar plot
      """
      # This plotting function can be used by several events. depending on whether
      categories = [
          int(action_dim_tuple[0]) for action_dim_tuple in value
      ]
      action_dim = value[0][1]
      # count the action categories
      category_counts = Counter(categories)
      # assemble counts for all categories. To make sure that actions that have not been chosen are still
      # represented in the plot, fill their counts with 0s
      cat_dict = {}
      for cat in range(action_dim):
          if cat in category_counts:
              cat_dict[cat] = category_counts[cat]
          else:
              cat_dict[cat] = 0
      # make bar plot where the frequencies of the categories are divided by the sum of the frequencies
      # in order to imitate a probability distribution
      fig_size = (min(14, max(7, action_dim // 2)), 7)
      fig = plt.figure(figsize=fig_size)
      plt.bar(
          x=cat_dict.keys(),
          height=np.array(list(cat_dict.values()))
          / sum(cat_dict.values()),
      )
      plt.ylim([0, 1])
      return fig
  
file_path: maze/maze/core/log_events/log_create_figure_functions.py
imports: from collections import Counter
  from typing import List, Tuple, Union
  import matplotlib.pyplot
  import numpy
  from maze.core.annotations import unused
label_desc: Use image node_id 5 for calling a global function with example usage: create_relative_bar_plot(value) and returns: fig