class_docstr: Dump training metrics to file.
class_docstr_tok: ["Dump","training","metrics","to","file","."]
code: def on_validate_end(
      self, trainer: Trainer, vessel: TrainingVesselBase
  ) -> None:
      self.valid_records.append(
          {
              k: v
              for k, v in trainer.metrics.items()
              if k.startswith("val/")
          }
      )
      pd.DataFrame.from_records(self.valid_records).to_csv(
          self.dirpath / "validation_result.csv", index=True
      )
  
imports: from __future__ import annotations
  import copy
  import os
  import shutil
  import time
  from datetime import datetime
  from pathlib import Path
  from typing import Any, List, TYPE_CHECKING
  import numpy
  import pandas
  import torch
  from qlib.log import get_module_logger
  from qlib.typehint import Literal
label_desc: Use image node_id 3 for calling the MetricsWriter obj's underlying member method code with example usage: obj.on_validate_end(trainer, vessel) without return types