code: def plot_recorder(
      lr_recorder, loss_recorder, beta: float = 0.95, **kwargs
  ) -> None:
      """Display the results of the LR grid search.
      Adapted from https://github.com/frgfm/Holocron/blob/master/holocron/trainer/core.py
  
      Args:
      ----
          lr_recorder: list of LR values
          loss_recorder: list of loss values
          beta (float, optional): smoothing factor
          **kwargs: keyword arguments from `matplotlib.pyplot.show`
      """
      if (
          len(lr_recorder) != len(loss_recorder)
          or len(lr_recorder) == 0
      ):
          raise AssertionError(
              "Both `lr_recorder` and `loss_recorder` should have the same length"
          )
  
      # Exp moving average of loss
      smoothed_losses = []
      avg_loss = 0.0
      for idx, loss in enumerate(loss_recorder):
          avg_loss = beta * avg_loss + (1 - beta) * loss
          smoothed_losses.append(avg_loss / (1 - beta ** (idx + 1)))
  
      # Properly rescale Y-axis
      data_slice = slice(
          min(len(loss_recorder) // 10, 10),
          # -min(len(loss_recorder) // 20, 5) if len(loss_recorder) >= 20 else len(loss_recorder)
          len(loss_recorder),
      )
      vals = np.array(smoothed_losses[data_slice])
      min_idx = vals.argmin()
      max_val = vals.max() if min_idx is None else vals[: min_idx + 1].max()  # type: ignore[misc]
      delta = max_val - vals[min_idx]
  
      plt.plot(lr_recorder[data_slice], smoothed_losses[data_slice])
      plt.xscale("log")
      plt.xlabel("Learning Rate")
      plt.ylabel("Training loss")
      plt.ylim(vals[min_idx] - 0.1 * delta, max_val + 0.2 * delta)
      plt.grid(True, linestyle="--", axis="x")
      plt.show(**kwargs)
  
file_path: doctr/references/detection/utils.py
imports: import pickle
  from typing import Dict, List
  import cv2
  import matplotlib.pyplot
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: plot_recorder(lr_recorder, loss_recorder, beta) without return types