code: def plot_metric(
      history: Union[
          List[Dict[str, Union[float, int]]], "pd.DataFrame"
      ],
      metric: str,
      *,
      label: Optional[str] = None,
      title: str = "",
      ax: Optional["matplotlib.axes.Axes"] = None,
  ):
      """
      Plot the training history in matplotlib for a given metric.
  
      Args:
          history (Union[List[Dict[str, Union[float, int]]], pd.DataFrame]): The training history to plot. Can be
              either a list of dictionary as returned by :func:`~poutyne.Model.fit()` or a Pandas DataFrame as read from a
              CSV output by the :class:`~poutyne.CSVLogger` callback.
          metric (str): The metric for which to output the plot.
          label (str, Optional[str]): A label for the metric. By default, the label is the same as the name of the metric.
          title (str, optional): A title for the plot. By default, no title.
          ax (Optional[matplotlib.axes.Axes], optional): A matplotlib :class:`~matplotlib.axes.Axes` to use. By default,
              the current axe is used.
      """
      _raise_error_if_matplotlib_not_there()
  
      if ax is None:
          ax = plt.gca()
  
      if label is None:
          train_label = metric
          valid_label = "val_" + metric
      else:
          train_label = "Training " + label
          valid_label = "Validation " + label
  
      val_metric_values = None
      if pd is not None and isinstance(history, pd.DataFrame):
          epochs = history["epoch"]
          metric_values = history[metric]
          if "val_" + metric in history:
              val_metric_values = history["val_" + metric]
      else:
          epochs = [entry["epoch"] for entry in history]
          metric_values = [entry[metric] for entry in history]
          if "val_" + metric in history[0]:
              val_metric_values = [
                  entry["val_" + metric] for entry in history
              ]
  
      ax.plot(epochs, metric_values, label=train_label)
      if val_metric_values is not None:
          ax.plot(epochs, val_metric_values, label=valid_label)
  
      ax.set_xlabel("Epochs")
      ax.set_ylabel(label)
      ax.xaxis.set_major_locator(MaxNLocator(integer=True))
  
      ax.legend()
      ax.set_title(title)
  
file_path: poutyne/poutyne/plotting.py
imports: import itertools
  import os
  from typing import Any, Dict, List, Optional, Tuple, Union
  from poutyne.utils import is_in_jupyter_notebook
label_desc: Use image node_id 10 for calling a global function with example usage: plot_metric(history, metric) without return types