    def log_epoch(
        self,
        train_metrics: Dict[str, Any],
        val_metrics: Dict[str, Any],
        epoch: int,
    ) -> None:
        """
        Called at the end of every epoch to log training and validation metrics.
        """
        self.log_scalars(
            {
                k: v
                for k, v in train_metrics.items()
                if isinstance(v, (int, float))
                if "_memory_MB" not in k  # W&B gives us much better system metrics
            },
            log_prefix="train",
            epoch=epoch,
        )
        self.log_scalars(
            {k: v for k, v in val_metrics.items() if isinstance(v, (int, float))},
            log_prefix="validation",
            epoch=epoch,
        )
Called at the end of every epoch to log training and validation metrics.
allennlp/training/callbacks/log_writer.py