Project: 040_MOS_Model_Synergy_for_Test-Time_Adaptation_on_LiDA | Function: hungarian_match_diff (iclr)

system: You are an expert Python programmer implementing algorithms from scientific papers.
Complete the masked function based on the algorithm description.
Follow Python best practices and maintain consistent code style.
Return **only** the complete Python function code.

user: Complete this Python function:

**DESCRIPTION:** Hungarian matching algorithm implementation for computing output-level box similarity between model predictions, used in the generalized Gram matrix computation

**KEY TERMS:** {
  "bbox_pred_1": "B^i (box set from model i)",
  "bbox_pred_2": "B^j (box set from model j)",
  "reg_cost": "L_{box} (box loss)",
  "linear_sum_assignment": "Hungarian matching algorithm"
}

**CONTEXT CODE:**                 pred_labels = pred_labels[remain_mask]
                pred_scores = pred_scores[remain_mask]
                pred_boxes = pred_boxes[remain_mask]
                if 'pred_cls_scores' in pred_dicts[b_idx]:
                    pred_cls_scores = pred_cls_scores[remain_mask]
                if 'pred_iou_scores' in pred_dicts[b_idx]:
                    pred_iou_scores = pred_iou_scores[remain_mask]

            labels_ignore_scores = np.array(cfg.SELF_TRAIN.SCORE_THRESH)[pred_labels - 1]
            ignore_mask = pred_scores < labels_ignore_scores
            pred_labels[ignore_mask] = -pred_labels[ignore_mask]

            if cfg.SELF_TRAIN.get('FIX_POS_NUM', None):
                expected_pos_num = pred_labels.shape[0] if pred_labels.shape[0] < cfg.SELF_TRAIN.FIX_POS_NUM else cfg.SELF_TRAIN.FIX_POS_NUM
                pred_labels[expected_pos_num:][pred_labels[expected_pos_num:] > 0] = - \
                pred_labels[expected_pos_num:][pred_labels[expected_pos_num:] > 0]

            gt_box = np.concatenate((pred_boxes,
                                     pred_labels.reshape(-1, 1),
                                     pred_scores.reshape(-1, 1)), axis=1)

        else:
            # no predicted boxes passes self-training score threshold
            gt_box = np.zeros((0, 9), dtype=np.float32)

        gt_infos = {
            'gt_boxes': gt_box,
            'cls_scores': pred_cls_scores,
            'iou_scores': pred_iou_scores,
            'memory_counter': np.zeros(gt_box.shape[0])
        }

        # record pseudo label to pseudo label dict
        if need_update:
            ensemble_func = getattr(memory_ensemble_utils, cfg.SELF_TRAIN.MEMORY_ENSEMBLE.NAME)
            gt_infos = memory_ensemble_utils.memory_ensemble(
                PSEUDO_LABELS[input_dict['frame_id'][b_idx]], gt_infos,
                cfg.SELF_TRAIN.MEMORY_ENSEMBLE, ensemble_func
            )

        # counter the number of ignore boxes for each class
        for i in range(ign_ps_nmeter.n):
            num_total_boxes = (np.abs(gt_infos['gt_boxes'][:, 7]) == (i+1)).sum()
            ign_ps_nmeter.update((gt_infos['gt_boxes'][:, 7] == -(i+1)).sum(), index=i)
            pos_ps_nmeter.update(num_total_boxes - ign_ps_nmeter.meters[i].val, index=i)

        NEW_PSEUDO_LABELS[input_dict['frame_id'][b_idx]] = gt_infos

    return pos_ps_nmeter, ign_ps_nmeter

def hungarian_match_diff(bbox_pred_1, bbox_pred_2):

    raise NotImplementedError("Function implementation has been masked for testing")

def vis_pred_pc(data_dict, pred_dict, c):
    from ..ops.roiaware_pool3d import roiaware_pool3d_utils
    from pcdet.utils.box_utils import remove_points_in_boxes3d, enlarge_box3d, \
        boxes3d_kitti_lidar_to_fakelidar, boxes_to_corners_3d

    points = data_dict['points'][data_dict['points'][:,0]==0][:,1:].cpu().numpy()
    # points = points[points[:,-1]==0]
    rgb = torch.tensor([179, 179, 179]).expand(points.shape[0],3).numpy()
    points = np.concatenate([points, rgb], axis=1)
    boxes = pred_dict['pred_boxes'].cpu().numpy()[:,:7]

    gt_boxes = data_dict['gt_boxes'][0].cpu().numpy()
    gt_boxes=None
    fg_point_masks = roiaware_pool3d_utils.points_in_boxes_cpu(points[:,:3], boxes)
    bg_points = points[fg_point_masks.sum(axis=0) == 0]
    fg_points = points[fg_point_masks.sum(axis=0) != 0]

    """------- Draw BG points -------"""
    bg_rgb = np.zeros((bg_points.shape[0], 3))
    bg_rgb[:, ] = [179, 179, 179]  # grey point
    bg_points_rgb = np.array(
        [[p[0], p[1], p[2], c[0], c[1], c[2]] for p, c in
         zip(bg_points, bg_rgb)])

    """------- Draw FG points -------"""
    fg_rgb = np.zeros((fg_points.shape[0], 3))
    fg_rgb[:, ] = [179, 179, 179]  # grey point
    # light blue 139,193,205
    # blue 98 161	179
    # light green 177	202	78
    # 	122,157,61
    fg_points_rgb = np.array(
        [[p[0], p[1], p[2], c[0], c[1], c[2]] for p, c in
         zip(fg_points, fg_rgb)])

    points_rgb = np.concatenate([bg_points_rgb, fg_points_rgb])


    boxes_to_draw = []
    """------- Draw known boxes -------"""
    if boxes is not None:
        for i in range(len(boxes_to_corners_3d(boxes).tolist())):
            box = boxes_to_corners_3d(boxes).tolist()[i]
            label = "{}".format(boxes[i])

            boxes_ref_label = {
                "corners": list(box),
                # optionally customize each label
                "label": None,
                "color": [0, 255, 0], # green 0, 255, 0
            }
            boxes_to_draw.append(boxes_ref_label)

    """------- Draw known boxes -------"""
    if gt_boxes is not None:
        for i in range(len(boxes_to_corners_3d(gt_boxes).tolist())):
            gt_box = boxes_to_corners_3d(gt_boxes).tolist()[i]
            label = "{}".format(gt_boxes[i])

            boxes_ref_label = {
                "corners": list(gt_box),
                # optionally customize each label
                "label": None, #str(i)
                "color": [255,0,0], # green 0, 255, 0
            }
            boxes_to_draw.append(boxes_ref_label)

    boxes_to_draw = np.array(boxes_to_draw)

    wandb.log(
        {"3d point cloud"+"/"+str(c):
            wandb.Object3D({
                "type": "lidar/beta",
                "points": points_rgb,
                "boxes": boxes_to_draw
            })
        })

def statistics_info(cfg, ret_dict, metric, disp_dict):
    for cur_thresh in cfg.MODEL.POST_PROCESSING.RECALL_THRESH_LIST:
        metric['recall_roi_%s' % str(cur_thresh)] += ret_dict.get('roi_%s' % str(cur_thresh), 0)
        metric['recall_rcnn_%s' % str(cur_thresh)] += ret_dict.get('rcnn_%s' % str(cur_thresh), 0)
    metric['gt_num'] += ret_dict.get('gt', 0)
    min_thresh = cfg.MODEL.POST_PROCESSING.RECALL_THRESH_LIST[0]
    disp_dict['recall_%s' % str(min_thresh)] = \
        '(%d, %d) / %d' % (metric['recall_roi_%s' % str(min_thresh)], metric['recall_rcnn_%s' % str(min_thresh)], metric['gt_num'])



Complete the function implementation replacing "raise NotImplementedError".