code: def plot_optimizer_errors(
      optimizer, logx=False, show=True, **figkwargs
  ):
      if "figsize" not in figkwargs:
          figkwargs["figsize"] = (12, 8)
  
      if not optimizer.events.logs:
          warnings.warn("There is no data to plot")
          return
  
      pd = load_pandas_module()
      history = pd.DataFrame(optimizer.events.logs)
  
      train = history[history.name == "train_error"]
      valid = history[history.name == "valid_error"]
      train_max = train.max()
  
      if train_max.epoch == train_max.n_updates:
          fig, ax = plt.subplots(1, 1, **figkwargs)
          # When number of epochs exactly the same as number of updates
          # plots per number of updates and epochs will be exactly the same
          plot_error_per_epoch(train, valid, logx=logx, ax=ax)
      else:
          fig, axes = plt.subplots(2, 1, **figkwargs)
          plot_errors_per_update(train, valid, logx=logx, ax=axes[0])
          plot_error_per_epoch(train, valid, logx=logx, ax=axes[1])
  
      if show:
          plt.show()
  
file_path: neupy/neupy/algorithms/plots.py
imports: import pkgutil
  import warnings
  import importlib
  import matplotlib.pyplot
label_desc: Use image node_id 5 for calling a global function with example usage: plot_optimizer_errors(optimizer, logx, show) without return types