class_docstr: A callback that computes additional metrics on a numpy representation of the dataset every n epochs.
  The computed values are logged to the output file of the pytorch lightning logger.
  
  Args:
      quantiles: The quantiles that are predicted.
      split: Specifies the split the batch comes from (i.e. from training or validation split)
      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","computes","additional","metrics","on","a","numpy","representation","of","the","dataset","every","n","epochs",".","The","computed","values","are","logged","to","the","output","file","of","the","pytorch","lightning","logger",".","Args",":","quantiles",":","The","quantiles","that","are","predicted",".","split",":","Specifies","the","split","the","batch","comes","from","(","i.e",".","from","training","or","validation","split",")","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 on_validation_epoch_end(
      self, trainer: Trainer, pl_module: MetaLightningModule
  ) -> None:
      if trainer.current_epoch % self.every_n_epochs:
          return
      dm_super = trainer.lightning_module.trainer.datamodule
      dm_val = dm_super.data_modules_val[0]
      dl = dm_val.val_dataloader()
      split = dm_val.splits.val()
      pred = []
      for batch in dl:
          batch = batch.to(pl_module.device)
          pred.append(
              pl_module.model(
                  supps=batch.support_set, query=batch.query_past
              )
          )
  
      # redo standardization for evaluation
      pred = split.data().rescale_dataset(torch.cat(pred, dim=0).cpu())
      pred = tensor_to_np(pred)
  
      # use only the length that should be included for evaluation
      pred = pred[:, : dm_val.prediction_length, ...]
      m = compute_metrics(
          pred,
          split.evaluation(),
          quantiles=self.quantiles,
          seasonality=get_seasonality(dm_val.meta.freq),
      )
      self.log("metrics", m)
  
file_path: gluonts/src/gluonts/nursery/few_shot_prediction/src/meta/callbacks/metric.py
imports: from typing import Optional, Union, List
  from pytorch_lightning import Callback, Trainer
  import torch
  from gluonts.time_feature import get_seasonality
  from meta.models.module import MetaLightningModule
  from meta.common.torch import tensor_to_np
  from meta.metrics.numpy import compute_metrics
label_desc: Use image node_id 2 for calling the QuantileMetricLoggerCallback obj's underlying member method code with example usage: obj.on_validation_epoch_end(trainer, pl_module) without return types