class_docstr: Sampler that handles limited quota for positive and negative samples.
  
  This is a custom Operator used inside HybridBlock.
  
  Parameters
  ----------
  num_sample : int, default is 128
      Number of samples for RCNN targets.
  pos_iou_thresh : float, default is 0.5
      Proposal whose IOU larger than ``pos_iou_thresh`` is regarded as positive samples.
  neg_iou_thresh_high : float, default is 0.5
      Proposal whose IOU smaller than ``neg_iou_thresh_high``
      and larger than ``neg_iou_thresh_low``
      is regarded as negative samples.
      Proposals with IOU in between ``pos_iou_thresh`` and ``neg_iou_thresh`` are
      ignored.
  neg_iou_thresh_low : float, default is 0.0
      See ``neg_iou_thresh_high``.
  pos_ratio : float, default is 0.25
      ``pos_ratio`` defines how many positive samples (``pos_ratio * num_sample``) is
      to be sampled.
  neg_ratio : float or None
      ``neg_ratio`` defines how many negative samples (``pos_ratio * num_sample``) is
      to be sampled. If ``None`` is provided, it equals to ``1 - pos_ratio``.
  fill_negative : bool
      If ``True``, negative samples will fill the gap caused by insufficient positive samples.
      For example, if ``num_sample`` is 100, ``pos_ratio`` and ``neg_ratio`` are both ``0.5``.
      Available positive sample and negative samples are 10 and 10000, which are typical values.
      Now, the output positive samples is 10(intact), since it's smaller than ``50(100 * 0.5)``,
      the negative samples will fill the rest ``40`` slots.
      If ``fill_negative == False``, the ``40`` slots is filled with ``-1(ignore)``.
class_docstr_tok: ["Sampler","that","handles","limited","quota","for","positive","and","negative","samples",".","This","is","a","custom","Operator","used","inside","HybridBlock",".","Parameters","--","--","--","--","--","num_sample",":","int",",","default","is","128","Number","of","samples","for","RCNN","targets",".","pos_iou_thresh",":","float",",","default","is","0.5","Proposal","whose","IOU","larger","than","``","pos_iou_thresh","``","is","regarded","as","positive","samples",".","neg_iou_thresh_high",":","float",",","default","is","0.5","Proposal","whose","IOU","smaller","than","``","neg_iou_thresh_high","``","and","larger","than","``","neg_iou_thresh_low","``","is","regarded","as","negative","samples",".","Proposals","with","IOU","in","between","``","pos_iou_thresh","``","and","``","neg_iou_thresh","``","are","ignored",".","neg_iou_thresh_low",":","float",",","default","is","0.0","See","``","neg_iou_thresh_high","``",".","pos_ratio",":","float",",","default","is","0.25","``","pos_ratio","``","defines","how","many","positive","samples","(","``","pos_ratio","*","num_sample","``",")","is","to","be","sampled",".","neg_ratio",":","float","or","None","``","neg_ratio","``","defines","how","many","negative","samples","(","``","pos_ratio","*","num_sample","``",")","is","to","be","sampled",".","If","``","None","``","is","provided",",","it","equals","to","``","1","-","pos_ratio","``",".","fill_negative",":","bool","If","``","True","``",",","negative","samples","will","fill","the","gap","caused","by","insufficient","positive","samples",".","For","example",",","if","``","num_sample","``","is","100",",","``","pos_ratio","``","and","``","neg_ratio","``","are","both","``","0.5","``",".","Available","positive","sample","and","negative","samples","are","10","and","10000",",","which","are","typical","values",".","Now",",","the","output","positive","samples","is","10","(","intact",")",",","since","it","'s","smaller","than","``","50","(","100","*","0.5",")","``",",","the","negative","samples","will","fill","the","rest","``","40","``","slots",".","If","``","fill_negative","==","False","``",",","the","``","40","``","slots","is","filled","with","``","-1","(","ignore",")","``","."]
code: def __init__(
      self,
      num_sample,
      pos_thresh,
      neg_thresh_high=0.5,
      neg_thresh_low=-np.inf,
      pos_ratio=0.5,
      neg_ratio=None,
      fill_negative=True,
  ):
      super(QuotaSamplerOp, self).__init__()
      self._num_sample = num_sample
      self._fill_negative = fill_negative
      if neg_ratio is None:
          self._neg_ratio = 1.0 - pos_ratio
      self._pos_ratio = pos_ratio
      assert (
          self._neg_ratio + self._pos_ratio
      ) <= 1.0, "Positive and negative ratio {} exceed 1".format(
          self._neg_ratio + self._pos_ratio
      )
      self._pos_thresh = min(1.0, max(0.0, pos_thresh))
      self._neg_thresh_high = min(1.0, max(0.0, neg_thresh_high))
      self._neg_thresh_low = neg_thresh_low
  
imports: from __future__ import absolute_import
  import numpy
  import mxnet
  from mxnet import gluon, nd
label_desc: Use image node_id 1 to create a new QuotaSamplerOp object from inherited base classes: mx.operator with example: obj = QuotaSamplerOp(num_sample, pos_thresh, neg_thresh_high, neg_thresh_low, pos_ratio, neg_ratio, fill_negative)