code: def plot_metric_images(
      fig: plt.Figure,
      title: str,
      graphmap: Mapping[
          str, list[float] | tuple[list[float], list[float]]
      ],
      imagemap: dict[str, np.ndarray],
      yscale: str = "log",
      avg_keys: tuple[str] = (LOSS_NAME,),
      window_fraction: int = 20,
  ) -> list:
      """
      Plot metric graph data with images below into figure `fig`. The intended use is for the graph data to be
      metrics from a training run and the images to be the batch and output from the last iteration. This uses
      `plot_metric_graph` to plot the metric graph.
  
      Args:
          fig: Figure object to plot into, reuse from previous plotting for flicker-free refreshing
          title: graph title
          graphmap: dictionary of named graph values, which are lists of values or (index, value) pairs
          imagemap: dictionary of named images to show with metric plot
          yscale: for metric plot, scale for y-axis compatible with `Axes.set_yscale`
          avg_keys: for metric plot, tuple of keys in `graphmap` to provide running average plots for
          window_fraction: for metric plot, what fraction of the graph value length to use as the running average window
  
      Returns:
          list of Axes objects for graph followed by images
      """
      gridshape = (4, max(1, len(imagemap)))
  
      graph = plt.subplot2grid(
          gridshape, (0, 0), colspan=gridshape[1], fig=fig
      )
  
      plot_metric_graph(
          graph, title, graphmap, yscale, avg_keys, window_fraction
      )
  
      axes = [graph]
      for i, n in enumerate(imagemap):
          im = plt.subplot2grid(gridshape, (1, i), rowspan=2, fig=fig)
  
          if imagemap[n].shape[0] == 3:
              im.imshow(imagemap[n].transpose([1, 2, 0]))
          else:
              im.imshow(np.squeeze(imagemap[n]), cmap="gray")
  
          im.set_title(
              f"{n}\n{imagemap[n].min():.3g} -> {imagemap[n].max():.3g}"
          )
          im.axis("off")
          axes.append(im)
  
      return axes
  
imports: from __future__ import annotations
  import copy
  from collections.abc import Callable, Mapping
  from enum import Enum
  from threading import RLock, Thread
  from typing import TYPE_CHECKING, Any
  import numpy
  import torch
  from monai.config import IgniteInfo
  from monai.utils.module import min_version, optional_import
label_desc: Use image node_id 2 for calling a global function with example usage: plot_metric_images(fig, title, graphmap, imagemap, yscale, avg_keys, window_fraction) and returns: axes