code: def plot_Q_history(results, colors, labels, ax=None):
      if ax is None:
          fig, ax = plt.subplots()
      ax.set_title("True function (Q) value over training iterations")
      ax.set_xlabel("training_iteration")
      ax.set_ylabel("Q(theta)")
      for i in range(len(results)):
          df = results[i].metrics_dataframe
          ax.plot(df["Q"], label=labels[i], color=colors[i])
      ax.legend()
  
file_path: ray/doc/source/tune/examples/pbt_visualization/pbt_visualization_utils.py
imports: import matplotlib.pyplot
  from matplotlib.animation import FuncAnimation, PillowWriter
  import numpy
label_desc: Use image node_id 5 for calling a global function with example usage: plot_Q_history(results, colors, labels, ax) without return types