code: def prepare_plot_data(log_files, names, metric="top1_err"):
      """Load logs and extract data for plotting error curves."""
      plot_data = []
      for file, name in zip(log_files, names):
          d, data = {}, logging.sort_log_data(
              logging.load_log_data(file)
          )
          for phase in ["train", "test"]:
              x = data[phase + "_epoch"]["epoch_ind"]
              y = data[phase + "_epoch"][metric]
              d["x_" + phase], d["y_" + phase] = x, y
              d[phase + "_label"] = (
                  "[{:5.2f}] ".format(min(y) if y else 0) + name
              )
          plot_data.append(d)
      assert len(plot_data) > 0, "No data to plot"
      return plot_data
  
file_path: pycls/pycls/core/plotting.py
imports: import colorlover
  import matplotlib.pyplot
  import plotly.graph_objs
  import plotly.offline
  import pycls.core.logging
label_desc: Use image node_id 2 for calling a global function with example usage: prepare_plot_data(log_files, names, metric) and returns: plot_data