code: def d2_get_uncertain_point_coords_with_randomness(
      coarse_logits,
      uncertainty_func,
      num_points,
      oversample_ratio,
      importance_sample_ratio,
  ):
      assert oversample_ratio >= 1
      assert (
          importance_sample_ratio <= 1 and importance_sample_ratio >= 0
      )
      num_boxes = coarse_logits.shape[0]
      num_sampled = int(num_points * oversample_ratio)
      point_coords = paddle.rand((num_boxes, num_sampled, 2))
      point_logits = point_sample(
          coarse_logits, point_coords, align_corners=False
      )
      # It is crucial to calculate uncertainty based on the sampled prediction value for the points.
      # Calculating uncertainties of the coarse predictions first and sampling them for points leads
      # to incorrect results.
      # To illustrate this: assume uncertainty_func(logits)=-abs(logits), a sampled point between
      # two coarse predictions with -1 and 1 logits has 0 logits, and therefore 0 uncertainty value.
      # However, if we calculate uncertainties for the coarse predictions first,
      # both will have -1 uncertainty, and the sampled point will get -1 uncertainty.
      point_uncertainties = uncertainty_func(point_logits)
      num_uncertain_points = int(importance_sample_ratio * num_points)
      num_random_points = num_points - num_uncertain_points
      idx = paddle.topk(
          point_uncertainties[:, 0, :], k=num_uncertain_points, axis=1
      )[1]
      shift = num_sampled * paddle.arange(num_boxes, dtype="int64")
      idx += shift[:, None]
      point_coords = point_coords.reshape((-1, 2))
      point_coords = paddle.index_select(
          point_coords, idx.flatten(), axis=0
      )
      point_coords = point_coords.reshape(
          (num_boxes, num_uncertain_points, 2)
      )
      if num_random_points > 0:
          point_coords = paddle.concat(
              [
                  point_coords,
                  paddle.rand((num_boxes, num_random_points, 2)),
              ],
              axis=1,
          )
      return point_coords
  
imports: import paddle
  import paddle.nn
  import paddle.nn.functional
  from scipy.optimize import linear_sum_assignment
  from paddlepanseg.cvlibs import manager, build_info_dict
  from paddlepanseg.core.runner import PanSegRunner
label_desc: Use image node_id 2 for calling a global function with example usage: d2_get_uncertain_point_coords_with_randomness(coarse_logits, uncertainty_func, num_points, oversample_ratio, importance_sample_ratio) and returns: point_coords