class_docstr: Online Hard Example Mining Sampler described in `Training Region-based
  Object Detectors with Online Hard Example Mining
  <https://arxiv.org/abs/1604.03540>`_.
docstr: Sample positive boxes.
  
  Args:
      assign_result (:obj:`AssignResult`): Assigned results
      num_expected (int): Number of expected positive samples
      bboxes (torch.Tensor, optional): Boxes. Defaults to None.
      feats (list[torch.Tensor], optional): Multi-level features.
          Defaults to None.
  
  Returns:
      torch.Tensor: Indices  of positive samples
docstr_tok: ["Sample","positive","boxes",".","Args",":","assign_result","(",":","obj",":","`","AssignResult","`",")",":","Assigned","results","num_expected","(","int",")",":","Number","of","expected","positive","samples","bboxes","(","torch.Tensor",",","optional",")",":","Boxes",".","Defaults","to","None",".","feats","(","list","[","torch.Tensor","]",",","optional",")",":","Multi-level","features",".","Defaults","to","None",".","Returns",":","torch.Tensor",":","Indices","of","positive","samples"]
code: def _sample_pos(
      self,
      assign_result,
      num_expected,
      bboxes=None,
      feats=None,
      **kwargs,
  ):
      """Sample positive boxes.
  
      Args:
          assign_result (:obj:`AssignResult`): Assigned results
          num_expected (int): Number of expected positive samples
          bboxes (torch.Tensor, optional): Boxes. Defaults to None.
          feats (list[torch.Tensor], optional): Multi-level features.
              Defaults to None.
  
      Returns:
          torch.Tensor: Indices  of positive samples
      """
      # Sample some hard positive samples
      pos_inds = torch.nonzero(
          assign_result.gt_inds > 0, as_tuple=False
      )
      if pos_inds.numel() != 0:
          pos_inds = pos_inds.squeeze(1)
      if pos_inds.numel() <= num_expected:
          return pos_inds
      else:
          return self.hard_mining(
              pos_inds,
              num_expected,
              bboxes[pos_inds],
              assign_result.labels[pos_inds],
              feats,
          )
  
file_path: mmdetection/mmdet/models/task_modules/samplers/ohem_sampler.py
imports: import torch
  from mmdet.registry import TASK_UTILS
  from mmdet.structures.bbox import bbox2roi
  from .base_sampler import BaseSampler
label_desc: Use image node_id 3 for calling the OHEMSampler obj's underlying member method code with example usage: obj._sample_pos(assign_result, num_expected, bboxes, feats) and returns: pos_inds, self