code: def libra_sample_via_interval(
      max_overlaps,
      full_set,
      num_expected,
      floor_thr,
      num_bins,
      bg_thresh,
  ):
      max_iou = max_overlaps.max()
      iou_interval = (max_iou - floor_thr) / num_bins
      per_num_expected = int(num_expected / num_bins)
  
      sampled_inds = []
      for i in range(num_bins):
          start_iou = floor_thr + i * iou_interval
          end_iou = floor_thr + (i + 1) * iou_interval
  
          tmp_set = set(
              np.where(
                  np.logical_and(
                      max_overlaps >= start_iou, max_overlaps < end_iou
                  )
              )[0]
          )
          tmp_inds = list(tmp_set & full_set)
  
          if len(tmp_inds) > per_num_expected:
              tmp_sampled_set = np.random.choice(
                  tmp_inds, size=per_num_expected, replace=False
              )
          else:
              tmp_sampled_set = np.array(tmp_inds, dtype=np.int32)
          sampled_inds.append(tmp_sampled_set)
  
      sampled_inds = np.concatenate(sampled_inds)
      if len(sampled_inds) < num_expected:
          num_extra = num_expected - len(sampled_inds)
          extra_inds = np.array(list(full_set - set(sampled_inds)))
          assert len(sampled_inds) + len(extra_inds) == len(
              full_set
          ), "sum of sampled_inds({}) and extra_inds({}) length must be equal with full_set({})!".format(
              len(sampled_inds), len(extra_inds), len(full_set)
          )
  
          if len(extra_inds) > num_extra:
              extra_inds = np.random.choice(
                  extra_inds, num_extra, replace=False
              )
          sampled_inds = np.concatenate([sampled_inds, extra_inds])
  
      return sampled_inds
  
file_path: PaddleDetection/ppdet/modeling/proposal_generator/target.py
imports: import numpy
  import paddle
  from ..bbox_utils import bbox2delta, bbox_overlaps
label_desc: Use image node_id 10 for calling a global function with example usage: libra_sample_via_interval(max_overlaps, full_set, num_expected, floor_thr, num_bins, bg_thresh) and returns: sampled_inds