class_docstr: A callback that stores plots of the validation losses and a macro-averaged validation loss curve every n epochs.
  
  Args:
      every_n_epochs: Specifies how often the plots are generated.
          Setting this to a large value can save time since plotting can be time consuming
          (especially when small datasets are used).
class_docstr_tok: ["A","callback","that","stores","plots","of","the","validation","losses","and","a","macro-averaged","validation","loss","curve","every","n","epochs",".","Args",":","every_n_epochs",":","Specifies","how","often","the","plots","are","generated",".","Setting","this","to","a","large","value","can","save","time","since","plotting","can","be","time","consuming","(","especially","when","small","datasets","are","used",")","."]
code: def plot_crps(self, trainer: Trainer, scaled: bool) -> None:
      cm = plt.get_cmap("tab20")
      suffix = "_scaled" if scaled else ""
      dm_super = trainer.lightning_module.trainer.datamodule
  
      fig, ax = plt.subplots()
      for i, dm_val in enumerate(dm_super.data_modules_val):
          c, steps = get_loss_steps(
              f"{dm_val.dataset_name}_val_crps{suffix}", trainer
          )
          ax.semilogy(
              steps,
              c,
              label=dm_val.dataset_name,
              alpha=1.0,
              color=cm.colors[i],
          )
  
      macro, steps = get_loss_steps(f"val_crps{suffix}_macro", trainer)
      ax.semilogy(steps, macro, "r--", label=f"val_crps{suffix}_macro")
      ticks = range(0, trainer.current_epoch + 1, self.every_n_epochs)
      labels = [str(t) for t in ticks]
      ax.set_xticks(ticks)
      ax.set_xticklabels(labels, rotation=45)
      ax.legend(
          ncol=2,
          loc="upper center",
          handletextpad=1.5,
          bbox_to_anchor=(0.5, 1.3),
          framealpha=0.5,
          prop={"size": 8},
      )
  
      fig.savefig(
          get_save_dir_from_csvlogger(trainer.logger)
          / f"val_crps{suffix}_macro.png",
          bbox_inches="tight",
      )
      plt.close(fig)
  
imports: from typing import Optional, Union, List
  from pytorch_lightning import Callback, Trainer
  import matplotlib.pyplot
  from meta.data.batch import TripletBatch
  from meta.models.module import MetaLightningModule
  from .common import get_save_dir_from_csvlogger, get_loss_steps
  from meta.data.batch import SeriesBatch
  from meta.vis.forecast import plot_quantile_forecast, plot_forecast_supportset_attention
label_desc: Use image node_id 4 for calling the MacroCRPSPlotCallback obj's underlying member method code with example usage: obj.plot_crps(trainer, scaled) without return types