def _log_early_stop_callback_metrics(callback, history):
    if callback:
        callback_attrs = _get_early_stop_callback_attrs(callback)
        if (callback_attrs is None):
            return
        (stopped_epoch, restore_best_weights, patience) = callback_attrs
        try_mlflow_log(mlflow.log_metric, 'stopped_epoch', stopped_epoch)
        if ((stopped_epoch != 0) and restore_best_weights):
            restored_epoch = (stopped_epoch - max(1, patience))
            try_mlflow_log(mlflow.log_metric, 'restored_epoch', restored_epoch)
            restored_metrics = {key: history.history[key][restored_epoch] for key in history.history.keys()}
            metric_key = next(iter(history.history), None)
            if (metric_key is not None):
                last_epoch = len(history.history[metric_key])
                try_mlflow_log(mlflow.log_metrics, restored_metrics, step=last_epoch)
def _log_early_stop_callback_metrics(callback, history):
    if callback:
        callback_attrs = _get_early_stop_callback_attrs(callback)
        if (callback_attrs is None):
            return
        (stopped_epoch, restore_best_weights, patience) = callback_attrs
        try_mlflow_log(mlflow.log_metric, 'stopped_epoch', stopped_epoch)
        if ((stopped_epoch != 0) and restore_best_weights):
            restored_epoch = (stopped_epoch - max(1, patience))
            try_mlflow_log(mlflow.log_metric, 'restored_epoch', restored_epoch)
            restored_metrics = {key: history.history[key][restored_epoch] for key in history.history.keys()}
            metric_key = next(iter(history.history), None)
            if (metric_key is not None):
                last_epoch = len(history.history[metric_key])
                try_mlflow_log(mlflow.log_metrics, restored_metrics, step=last_epoch)