code: def libra_sample_neg(
      max_overlaps,
      max_classes,
      neg_inds,
      num_expected,
      floor_thr=-1,
      floor_fraction=0,
      num_bins=3,
      bg_thresh=0.5,
  ):
      if len(neg_inds) <= num_expected:
          return neg_inds
      else:
          # balance sampling for negative samples
          neg_set = set(neg_inds.tolist())
          if floor_thr > 0:
              floor_set = set(
                  np.where(
                      np.logical_and(
                          max_overlaps >= 0, max_overlaps < floor_thr
                      )
                  )[0]
              )
              iou_sampling_set = set(
                  np.where(max_overlaps >= floor_thr)[0]
              )
          elif floor_thr == 0:
              floor_set = set(np.where(max_overlaps == 0)[0])
              iou_sampling_set = set(
                  np.where(max_overlaps > floor_thr)[0]
              )
          else:
              floor_set = set()
              iou_sampling_set = set(
                  np.where(max_overlaps > floor_thr)[0]
              )
              floor_thr = 0
  
          floor_neg_inds = list(floor_set & neg_set)
          iou_sampling_neg_inds = list(iou_sampling_set & neg_set)
  
          num_expected_iou_sampling = int(
              num_expected * (1 - floor_fraction)
          )
          if len(iou_sampling_neg_inds) > num_expected_iou_sampling:
              if num_bins >= 2:
                  iou_sampled_inds = libra_sample_via_interval(
                      max_overlaps,
                      set(iou_sampling_neg_inds),
                      num_expected_iou_sampling,
                      floor_thr,
                      num_bins,
                      bg_thresh,
                  )
              else:
                  iou_sampled_inds = np.random.choice(
                      iou_sampling_neg_inds,
                      size=num_expected_iou_sampling,
                      replace=False,
                  )
          else:
              iou_sampled_inds = np.array(
                  iou_sampling_neg_inds, dtype=np.int32
              )
          num_expected_floor = num_expected - len(iou_sampled_inds)
          if len(floor_neg_inds) > num_expected_floor:
              sampled_floor_inds = np.random.choice(
                  floor_neg_inds, size=num_expected_floor, replace=False
              )
          else:
              sampled_floor_inds = np.array(
                  floor_neg_inds, dtype=np.int32
              )
          sampled_inds = np.concatenate(
              (sampled_floor_inds, iou_sampled_inds)
          )
          if len(sampled_inds) < num_expected:
              num_extra = num_expected - len(sampled_inds)
              extra_inds = np.array(list(neg_set - set(sampled_inds)))
              if len(extra_inds) > num_extra:
                  extra_inds = np.random.choice(
                      extra_inds, size=num_extra, replace=False
                  )
              sampled_inds = np.concatenate((sampled_inds, extra_inds))
          return paddle.to_tensor(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 11 for calling a global function with example usage: libra_sample_neg(max_overlaps, max_classes, neg_inds, num_expected, floor_thr, floor_fraction, num_bins, bg_thresh) and returns: neg_inds, paddle