def METHOD_NAME(**kwargs):
    assert kwargs.get('dst_model', None) is not None, \
        'Please config param: dst_model, to save averaged model'
    dst_model = kwargs['dst_model']
    assert kwargs.get('src_path', None) is not None, \
        'Please config param: src_path, path of checkpoints to be averaged'
    src_path = kwargs['src_path']
    val_best = kwargs.get('val_best',
                          'True')  # average with best loss or final models
    avg_num = kwargs.get('avg_num', 5)  # nums for averaging model
    min_epoch = kwargs.get('min_epoch',
                           5)  # min epoch used for averaging model
    max_epoch = kwargs.get('max_epoch',
                           65536)  # max epoch used for averaging model
    val_scores = []
    if val_best:
        yamls = glob.glob('{}/[!config]*.yaml'.format(src_path))
        for y in yamls:
            with open(y, 'r') as f:
                dic_yaml = yaml.load(f, Loader=yaml.FullLoader)
                print(y, dic_yaml)
                loss = dic_yaml['cv_loss']
                epoch = dic_yaml['epoch']
                if epoch >= min_epoch and epoch <= max_epoch:
                    val_scores += [[epoch, loss]]
        val_scores = np.array(val_scores)
        sort_idx = np.argsort(val_scores[:, -1])
        sorted_val_scores = val_scores[sort_idx][::1]
        logger.info('best val scores = ' + str(sorted_val_scores[:avg_num, 1]))
        logger.info('selected epochs = '
                    + str(sorted_val_scores[:avg_num, 0].astype(np.int64)))
        path_list = [
            src_path + '/{}.pt'.format(int(epoch))
            for epoch in sorted_val_scores[:avg_num, 0]
        ]
    else:
        path_list = glob.glob('{}/[!avg][!final]*.pt'.format(src_path))
        path_list = sorted(path_list, key=os.path.getmtime)
        path_list = path_list[-avg_num:]
    logger.info(path_list)
    avg = None
    # assert num == len(path_list)
    if avg_num > len(path_list):
        logger.info(
            'insufficient epochs for averaging, exist num:{}, need:{}'.format(
                len(path_list), avg_num))
        logger.info('select epoch on best val:{}'.format(path_list[0]))
        path_list = [path_list[0]]
    for path in path_list:
        logger.info('Processing {}'.format(path))
        states = torch.load(path, map_location=torch.device('cpu'))
        if avg is None:
            avg = states
        else:
            for k in avg.keys():
                avg[k] += states[k]
    # average
    for k in avg.keys():
        if avg[k] is not None:
            # pytorch 1.6 use true_divide instead of /=
            # avg[k] = torch.true_divide(avg[k], num)
            avg[k] = torch.true_divide(avg[k], len(path_list))
    logger.info('Saving to {}'.format(dst_model))
    torch.save(avg, dst_model)
    return dst_model