code: def log_confusion_matrix(epoch, logs):
      # Use the model to predict the values from the validation dataset.
      test_pred_raw = model.predict(test_images)
      test_pred = np.argmax(test_pred_raw, axis=1)
  
      # Calculate the confusion matrix.
      cm = sklearn.metrics.confusion_matrix(test_labels, test_pred)
      # Log the confusion matrix as an image summary.
      figure = plot_confusion_matrix(cm, class_names=class_names)
      cm_image = plot_to_image(figure)
  
      # Log the confusion matrix as an image summary.
      with file_writer_cm.as_default():
          tf.summary.image("Confusion Matrix", cm_image, step=epoch)
  
file_path: guildai/examples/tensorboard/images.py
imports: import os
  from datetime import datetime
  import io
  import itertools
  from packaging import version
  import tensorflow
  from tensorflow import keras
  import matplotlib.pyplot
  import numpy
  import sklearn.metrics
label_desc: Use image node_id 4 for calling a global function with example usage: log_confusion_matrix(epoch, logs) without return types