code: def subsample(self, labels):
      # type: (List[Tensor]) -> List[Tensor]
      # BalancedPositiveNegativeSampler
      sampled_pos_inds, sampled_neg_inds = self.fg_bg_sampler(labels)
      sampled_inds = []
      # 遍历每张图片的正负样本索引
      for img_idx, (pos_inds_img, neg_inds_img) in enumerate(
          zip(sampled_pos_inds, sampled_neg_inds)
      ):
          # 记录所有采集样本索引（包括正样本和负样本）
          # img_sampled_inds = torch.nonzero(pos_inds_img | neg_inds_img).squeeze(1)
          img_sampled_inds = torch.where(pos_inds_img | neg_inds_img)[0]
          sampled_inds.append(img_sampled_inds)
      return sampled_inds
  
file_path: deep-learning-for-image-processing/pytorch_object_detection/faster_rcnn/network_files/roi_head.py
imports: from typing import Optional, List, Dict, Tuple
  import torch
  from torch import Tensor
  import torch.nn.functional
  from .None import det_utils
  from .None import boxes
label_desc: Use image node_id 3 for calling the RoIHeads obj's underlying member method code with example usage: obj.subsample(labels) and returns: sampled_inds