code: def brier_plot(
      brier_scores,
      algorithm_names=None,
      class_names=None,
      title=None,
      filename=None,
      callbacks=None,
  ):
      sns.set_style("whitegrid")
  
      # Dynamically set the size of the plot based on the number of labels
      # Use minimum size to prevent plot from being too small
      default_width, default_height = plt.rcParams.get("figure.figsize")
      width = max(default_width, len(class_names) / 2)
      height = max(default_height, len(class_names) / 2)
      fig, ax = plt.subplots(figsize=(width, height))
  
      if title is not None:
          plt.title(title)
  
      colors = plt.get_cmap("tab10").colors
  
      n_algorithms = brier_scores.shape[1]
      n_classes = brier_scores.shape[0]
      x = np.arange(n_classes)
  
      max_width = 0.35
      bar_width = min(0.5 / n_algorithms, max_width)
      bar_left = -bar_width * (n_algorithms // 2) + (
          (bar_width / 2) if (n_algorithms % 2) == 0 else 0
      )
  
      ax.grid(which="both")
      ax.grid(which="minor", alpha=0.5)
      ax.grid(which="major", alpha=0.75)
      ax.set_xlabel("class")
      ax.set_ylabel("brier score")
      if class_names is not None:
          ax.set_xticks(
              x,
              class_names,
              rotation=45,
              ha="center",
          )
      else:
          ax.set_xticks(
              x,
              [str(i) for i in range(n_classes)],
              rotation=45,
              ha="center",
          )
  
      for i in range(n_algorithms):
          # Plot bar for each class
          label = (
              algorithm_names[i]
              if algorithm_names is not None
              and i < len(algorithm_names)
              else f"Model {i}"
          )
          ax.bar(
              x + bar_left + (bar_width * i),
              brier_scores[:, i],
              bar_width,
              color=colors[i],
              label=label,
          )
  
      ax.legend()
      fig.tight_layout()
      visualize_callbacks(callbacks, plt.gcf())
      if filename:
          plt.savefig(filename)
      else:
          plt.show()
  
imports: import copy
  import logging
  from collections import Counter
  from sys import platform
  from typing import Dict, List
  import numpy
  import pandas
  import ptitprince
  from packaging import version
  from ludwig.constants import SPACE, TRAINING, VALIDATION
label_desc: Use image node_id 17 for calling a global function with example usage: brier_plot(brier_scores, algorithm_names, class_names, title, filename, callbacks) without return types