Upgrading callback to newest format

I came across an XGBoost out-of-fold prediction callback in a post elsewhere (Get out-of-fold predictions from xgboost.cv in python) and shown below. However, it does not work because it is not in the new callback format introduced with XGBoost 1.6 and results in an error message saying so. I have looked for documentation on upgrading this callback or understanding why it is not in the correct format, but I have not found anything useful. Can someone provide how to update this callback or provide me with some references to do this?

def oof_prediction(): “”" Dirty global variable callback hack. “”"

global cv_prediction_dict

def callback(env):
    """internal function"""        
    cv_prediction_list = []

    for i in [0, 1, 2, 3, 4]:

    cv_prediction_dict['cv'] = cv_prediction_list

return callback

Apologies for the withdrawn post. You can take a look at this https://xgboost.readthedocs.io/en/stable/python/callbacks.html , which contains a brief description and a link to a worked example.

Thanks, but I have looked at that page previously and it does not provide any information on how to upgrade the callback. It only provides information on the new callback format. From this, there is no indication of why the callback as written will not work. I am looking for information on what is wrong with the current callback and how I might upgrade it.