class_docstr: Keras callback for logging metrics and final model with MLflow.
  
  Metrics are logged after every epoch. The logger keeps track of the best model based on the
  validation metric. At the end of the training, the best model is logged with MLflow.
class_docstr_tok: ["Keras","callback","for","logging","metrics","and","final","model","with","MLflow",".","Metrics","are","logged","after","every","epoch",".","The","logger","keeps","track","of","the","best","model","based","on","the","validation","metric",".","At","the","end","of","the","training",",","the","best","model","is","logged","with","MLflow","."]
docstr: Log Keras metrics with MLflow. Update the best model if the model improved on the validation
  data.
docstr_tok: ["Log","Keras","metrics","with","MLflow",".","Update","the","best","model","if","the","model","improved","on","the","validation","data","."]
code: def on_epoch_end(self, epoch, logs=None):
      """
      Log Keras metrics with MLflow. Update the best model if the model improved on the validation
      data.
      """
      if not logs:
          return
      for name, value in logs.items():
          name = (
              "valid_" + name[4:]
              if name.startswith("val_")
              else "train_" + name
          )
          mlflow.log_metric(name, value)
      val_loss = logs["val_loss"]
      if val_loss < self._best_val_loss:
          # Save the "best" weights
          self._best_val_loss = val_loss
          self._best_weights = [
              x.copy() for x in self._model.get_weights()
          ]
  
imports: import math
  import os
  import tarfile
  import click
  import keras
  import numpy
  import tensorflow
  from image_pyfunc import decode_and_resize_image, log_model
  from keras.applications import vgg16
  from keras.callbacks import Callback
  from keras.layers import Dense, Flatten, Input, Lambda
  from keras.models import Model
  from keras.utils import np_utils
  from sklearn.model_selection import train_test_split
  import mlflow
  from mlflow.models import infer_signature
label_desc: Use image node_id 2 for calling the MLflowLogger obj's underlying member method code with example usage: obj.on_epoch_end(epoch, logs) without return types