code: def plot(xkey, coords, data):
      # determine the plotfile path
      labels = sorted(
          [(xkey, 0)] + coords.items(),
          key=lambda tpl: specs.keys().index(tpl[0]),
      )
      title = ", ".join(
          "%s: %s" % tpl
          for tpl in labels
          if tpl[0] != "examples" and tpl[0] != xkey
      )
      labels = [(key[0], value) for key, value in labels]
      plotfile = (
          "runtime_"
          + xkey
          + "_"
          + "_".join("%s%s" % tpl for tpl in labels)
          + ".png"
      )
      plotfile = os.path.join(plotdir, plotfile)
  
      # get x and y data to plot
      x = [d[xkey] for d in data]
      ykeys = ["tf_cpu", "tf_gpu", "td"]
      y = {
          ykey: [d["times"][ykey]["mean"] for d in data]
          for ykey in ykeys
      }
      markers = dict(zip(ykeys, ("s", "o", "D")))
  
      # do the plot
      fig, axes = plt.subplots()
      for ykey, _y in y.items():
          axes.plot(x, _y, "-" + markers[ykey], label=ykey)
  
      axes.set_xlabel(xkey)
      axes.set_ylabel("time per batch [s]")
      axes.set_title(title)
      if xkey != "units":
          axes.set_xscale("log")
      axes.legend(loc="best")
  
      fig.savefig(plotfile)
      fig.clf()
  
file_path: tfdeploy/tests/perf/create_plots.py
imports: import os
  import json
  import itertools
  import collections
  import matplotlib.pyplot
  from measure_runtimes import specs, output_file
label_desc: Use image node_id 1 for calling a global function with example usage: plot(xkey, coords, data) without return types