code: def plot_histograms(
      train: Iterable[float],
      test: Iterable[float],
      xlabel: Text = "x",
      thresh: Optional[float] = None,
  ) -> plt.Figure:
      """Plot histograms of training versus test metrics."""
      xmin = min(np.min(train), np.min(test))
      xmax = max(np.max(train), np.max(test))
      bins = np.linspace(xmin, xmax, 100)
      fig = plt.figure()
      plt.hist(
          test,
          bins=bins,
          density=True,
          alpha=0.5,
          label="test",
          log="y",
      )
      plt.hist(
          train,
          bins=bins,
          density=True,
          alpha=0.5,
          label="train",
          log="y",
      )
      if thresh is not None:
          plt.axvline(thresh, c="r", label=f"threshold = {thresh:.3f}")
      plt.xlabel(xlabel)
      plt.ylabel("normalized counts (density)")
      plt.legend()
      return fig
  
imports: from typing import Text, Iterable, Optional
  import matplotlib.pyplot
  import numpy
  from sklearn import metrics
label_desc: Use image node_id 3 for calling a global function with example usage: plot_histograms(train, test, xlabel, thresh) and returns: fig