class_docstr: HardNegativeSampler is used to suppress false positive rate in classification tasks.
  During training, it selects negative samples with high prediction scores.
  
  The training workflow is described as the follows:
  1) forward network and get prediction scores (classification prob/logits) for all the samples;
  2) use hard negative sampler to choose negative samples with high prediction scores and some positive samples;
  3) compute classification loss for the selected samples;
  4) do back propagation.
  
  Args:
      batch_size_per_image: number of training samples to be randomly selected per image
      positive_fraction: percentage of positive elements in the selected samples
      min_neg: minimum number of negative samples to select if possible.
      pool_size: when we need ``num_neg`` hard negative samples, they will be randomly selected from
          ``num_neg * pool_size`` negative samples with the highest prediction scores.
          Larger ``pool_size`` gives more randomness, yet selects negative samples that are less 'hard',
          i.e., negative samples with lower prediction scores.
docstr: Select positive samples
  
  Args:
      positive: indices of positive samples, sized (P,),
          where P is the number of positive samples
      num_pos: number of positive samples to sample
      labels: labels for all samples, sized (A,),
          where A is the number of samples.
  
  Returns:
      binary mask of positive samples to choose, sized (A,),
          where A is the number of samples in one image
docstr_tok: ["Select","positive","samples","Args",":","positive",":","indices","of","positive","samples",",","sized","(","P",",",")",",","where","P","is","the","number","of","positive","samples","num_pos",":","number","of","positive","samples","to","sample","labels",":","labels","for","all","samples",",","sized","(","A",",",")",",","where","A","is","the","number","of","samples",".","Returns",":","binary","mask","of","positive","samples","to","choose",",","sized","(","A",",",")",",","where","A","is","the","number","of","samples","in","one","image"]
code: def select_positives(
      self, positive: Tensor, num_pos: int, labels: Tensor
  ) -> Tensor:
      """
      Select positive samples
  
      Args:
          positive: indices of positive samples, sized (P,),
              where P is the number of positive samples
          num_pos: number of positive samples to sample
          labels: labels for all samples, sized (A,),
              where A is the number of samples.
  
      Returns:
          binary mask of positive samples to choose, sized (A,),
              where A is the number of samples in one image
      """
      if positive.numel() > labels.numel():
          raise ValueError(
              "The number of positive samples should not be larger than the number of all samples."
          )
  
      perm1 = torch.randperm(positive.numel(), device=positive.device)[
          :num_pos
      ]
      pos_idx_per_image = positive[perm1]
  
      # output a binary mask with same size of labels that indicates selected positive samples.
      pos_idx_per_image_mask = torch.zeros_like(
          labels, dtype=torch.uint8
      )
      pos_idx_per_image_mask[pos_idx_per_image] = 1
      return pos_idx_per_image_mask
  
file_path: MONAI/monai/apps/detection/utils/hard_negative_sampler.py
imports: from __future__ import annotations
  import logging
  import torch
  from torch import Tensor
label_desc: Use image node_id 7 for calling the HardNegativeSampler obj's underlying member method code with example usage: obj.select_positives(positive, num_pos, labels) and returns: pos_idx_per_image_mask