code: def swiss_knife_plotter(
      img_path, plots=None, scatters=None, hists=None, options=None
  ):
      """A multi-functional *standalone* wrapper; reduces boilerplate.
  
      Args:
          img_path (str): A path to the place where the image should be written.
          plots (list of dict, optional): A list of curves that needs `plt.plot`.
          scatters (list of dict, optional): A list of scatter plots that needs `plt.scatter`.
          hists (list of histograms, optional): A list of histograms that needs `plt.hist`.
          options (dict, optional): A dictionary of optional arguments. Possible entries include
              - xscale (str): Scale of xaxis.
              - yscale (str): Scale of yaxis.
              - xlabel (str): Label of xaxis.
              - ylabel (str): Label of yaxis.
              - title (str): Title of the plot.
              - cycle_linestyle (bool): Cycle through matplotlib's possible line styles if True.
  
      Returns:
          Nothing.
      """
      img_dir = os.path.dirname(img_path)
      if not os.path.exists(img_dir):
          os.makedirs(img_dir)
  
      if plots is None:
          plots = ()
      if scatters is None:
          scatters = ()
      if hists is None:
          hists = ()
      if options is None:
          options = {}
  
      plt.figure(dpi=300)
      if "xscale" in options:
          plt.xscale(options["xscale"])
      if "yscale" in options:
          plt.yscale(options["yscale"])
      if "xlabel" in options:
          plt.xlabel(options["xlabel"])
      if "ylabel" in options:
          plt.ylabel(options["ylabel"])
      if "title" in options:
          plt.title(options["title"])
  
      cycle_linestyle = options.get("cycle_linestyle", False)
      cycler = (
          itertools.cycle(["-", "--", "-.", ":"])
          if cycle_linestyle
          else None
      )
      for entry in plots:
          kwargs = {
              key: entry[key]
              for key in entry
              if key != "x" and key != "y"
          }
          entry["x"], entry["y"] = to_numpy(entry["x"], entry["y"])
          if cycle_linestyle:
              kwargs["linestyle"] = next(cycler)
          plt.plot(entry["x"], entry["y"], **kwargs)
  
      for entry in scatters:
          kwargs = {
              key: entry[key]
              for key in entry
              if key != "x" and key != "y"
          }
          entry["x"], entry["y"] = to_numpy(entry["x"], entry["y"])
          plt.scatter(entry["x"], entry["y"], **kwargs)
  
      for entry in hists:
          kwargs = {key: entry[key] for key in entry if key != "x"}
          entry["x"] = to_numpy(entry["x"])
          plt.hist(entry["x"], **kwargs)
  
      if len(plots) > 0 or len(scatters) > 0:
          plt.legend()
      plt.tight_layout()
      plt.savefig(img_path)
      plt.close()
  
file_path: torchsde/diagnostics/utils.py
imports: import itertools
  import os
  import random
  import matplotlib.pyplot
  import numpy
  import torch
  from scipy import stats
  from torchsde.types import Optional, Tensor, Sequence, Union, Callable
label_desc: Use image node_id 7 for calling a global function with example usage: swiss_knife_plotter(img_path, plots, scatters, hists, options) without return types