def assign(predictions,
           targets,
           img_w,
           img_h,
           distance_cost_weight=3.0,
           cls_cost_weight=1.0):
    """
    computes dynamicly matching based on the cost, including cls cost and lane similarity cost
    Args:
        predictions (Tensor): predictions predicted by each stage, shape: (num_priors, 78)
        targets (Tensor): lane targets, shape: (num_targets, 78)
    return:
        matched_row_inds (Tensor): matched predictions, shape: (num_targets)
        matched_col_inds (Tensor): matched targets, shape: (num_targets)
    """
    predictions = predictions.detach().clone()
    predictions[:, 3] *= img_w - 1
    predictions[:, 6:] *= img_w - 1

    targets = targets.detach().clone()
    distances_score = distance_cost(predictions, targets, img_w)
    distances_score = 1 - distances_score / paddle.max(x=distances_score) + 0.01

    cls_score = focal_cost(predictions[:, :2], targets[:, 1].cast('int64'))

    num_priors = predictions.shape[0]
    num_targets = targets.shape[0]
    target_start_xys = targets[:, 2:4]
    target_start_xys[..., 0] *= (img_h - 1)
    prediction_start_xys = predictions[:, 2:4]
    prediction_start_xys[..., 0] *= (img_h - 1)
    start_xys_score = cdist_paddle(
        prediction_start_xys, target_start_xys,
        p=2).reshape([num_priors, num_targets])

    start_xys_score = 1 - start_xys_score / paddle.max(x=start_xys_score) + 0.01

    target_thetas = targets[:, 4].unsqueeze(axis=-1)
    theta_score = cdist_paddle(
        predictions[:, 4].unsqueeze(axis=-1), target_thetas,
        p=1).reshape([num_priors, num_targets]) * 180
    theta_score = 1 - theta_score / paddle.max(x=theta_score) + 0.01

    cost = -(distances_score * start_xys_score * theta_score
             )**2 * distance_cost_weight + cls_score * cls_cost_weight
    iou = line_iou(predictions[..., 6:], targets[..., 6:], img_w, aligned=False)

    matched_row_inds, matched_col_inds = dynamic_k_assign(cost, iou)
    return matched_row_inds, matched_col_inds

    computes dynamicly matching based on the cost, including cls cost and lane similarity cost
    Args:
        predictions (Tensor): predictions predicted by each stage, shape: (num_priors, 78)
        targets (Tensor): lane targets, shape: (num_targets, 78)
    return:
        matched_row_inds (Tensor): matched predictions, shape: (num_targets)
        matched_col_inds (Tensor): matched targets, shape: (num_targets)
    
ppdet/modeling/assigners/clrnet_assigner.py