def _run_and_log_function(self, original, args, kwargs, unlogged_params, callback_arg_index):
    if (not mlflow.active_run()):
        try_mlflow_log(mlflow.start_run)
        auto_end_run = True
    else:
        auto_end_run = False
    log_fn_args_as_params(original, args, kwargs, unlogged_params)
    early_stop_callback = None
    if (len(args) > callback_arg_index):
        tmp_list = list(args)
        early_stop_callback = _early_stop_check(tmp_list[callback_arg_index])
        tmp_list[callback_arg_index] += [__MLflowKerasCallback()]
        args = tuple(tmp_list)
    elif ('callbacks' in kwargs):
        early_stop_callback = _early_stop_check(kwargs['callbacks'])
        kwargs['callbacks'] += [__MLflowKerasCallback()]
    else:
        kwargs['callbacks'] = [__MLflowKerasCallback()]
    _log_early_stop_callback_params(early_stop_callback)
    history = original(self, *args, **kwargs)
    _log_early_stop_callback_metrics(early_stop_callback, history)
    if auto_end_run:
        try_mlflow_log(mlflow.end_run)
    return history
def _run_and_log_function(self, original, args, kwargs, unlogged_params, callback_arg_index):
    if (not mlflow.active_run()):
        try_mlflow_log(mlflow.start_run)
        auto_end_run = True
    else:
        auto_end_run = False
    log_fn_args_as_params(original, args, kwargs, unlogged_params)
    early_stop_callback = None
    if (len(args) > callback_arg_index):
        tmp_list = list(args)
        early_stop_callback = _early_stop_check(tmp_list[callback_arg_index])
        tmp_list[callback_arg_index] += [__MLflowKerasCallback()]
        args = tuple(tmp_list)
    elif ('callbacks' in kwargs):
        early_stop_callback = _early_stop_check(kwargs['callbacks'])
        kwargs['callbacks'] += [__MLflowKerasCallback()]
    else:
        kwargs['callbacks'] = [__MLflowKerasCallback()]
    _log_early_stop_callback_params(early_stop_callback)
    history = original(self, *args, **kwargs)
    _log_early_stop_callback_metrics(early_stop_callback, history)
    if auto_end_run:
        try_mlflow_log(mlflow.end_run)
    return history