docstr: this is the second forward pass through the second stage (features from stage one are re-used).
  samples few rois in detection_target_layer and forwards only those for loss computation.
  :param batch_gt_class_ids: list over batch elements. Each element is a list over the corresponding roi target labels.
  :param batch_gt_boxes: list over batch elements. Each element is a list over the corresponding roi target coordinates.
  :param batch_gt_masks: list over batch elements. Each element is binary mask of shape (n_gt_rois, y, x, (z), c)
  :return: sample_logits: (n_sampled_rois, n_classes) predicted class scores.
  :return: sample_boxes: (n_sampled_rois, n_classes, 2 * dim) predicted corrections to be applied to proposals for refinement.
  :return: sample_mask: (n_sampled_rois, n_classes, y, x, (z)) predicted masks per class and proposal.
  :return: sample_target_class_ids: (n_sampled_rois) target class labels of sampled proposals.
  :return: sample_target_deltas: (n_sampled_rois, 2 * dim) target deltas of sampled proposals for box refinement.
  :return: sample_target_masks: (n_sampled_rois, y, x, (z)) target masks of sampled proposals.
  :return: sample_proposals: (n_sampled_rois, 2 * dim) RPN output for sampled proposals. only for monitoring/plotting.
docstr_tok: ["this","is","the","second","forward","pass","through","the","second","stage","(","features","from","stage","one","are","re-used",")",".","samples","few","rois","in","detection_target_layer","and","forwards","only","those","for","loss","computation",".",":","param","batch_gt_class_ids",":","list","over","batch","elements",".","Each","element","is","a","list","over","the","corresponding","roi","target","labels",".",":","param","batch_gt_boxes",":","list","over","batch","elements",".","Each","element","is","a","list","over","the","corresponding","roi","target","coordinates",".",":","param","batch_gt_masks",":","list","over","batch","elements",".","Each","element","is","binary","mask","of","shape","(","n_gt_rois",",","y",",","x",",","(","z",")",",","c",")",":","return",":","sample_logits",":","(","n_sampled_rois",",","n_classes",")","predicted","class","scores",".",":","return",":","sample_boxes",":","(","n_sampled_rois",",","n_classes",",","2","*","dim",")","predicted","corrections","to","be","applied","to","proposals","for","refinement",".",":","return",":","sample_mask",":","(","n_sampled_rois",",","n_classes",",","y",",","x",",","(","z",")",")","predicted","masks","per","class","and","proposal",".",":","return",":","sample_target_class_ids",":","(","n_sampled_rois",")","target","class","labels","of","sampled","proposals",".",":","return",":","sample_target_deltas",":","(","n_sampled_rois",",","2","*","dim",")","target","deltas","of","sampled","proposals","for","box","refinement",".",":","return",":","sample_target_masks",":","(","n_sampled_rois",",","y",",","x",",","(","z",")",")","target","masks","of","sampled","proposals",".",":","return",":","sample_proposals",":","(","n_sampled_rois",",","2","*","dim",")","RPN","output","for","sampled","proposals",".","only","for","monitoring\/plotting","."]
code: def loss_samples_forward(
      self, batch_gt_class_ids, batch_gt_boxes, batch_gt_masks
  ):
      """
      this is the second forward pass through the second stage (features from stage one are re-used).
      samples few rois in detection_target_layer and forwards only those for loss computation.
      :param batch_gt_class_ids: list over batch elements. Each element is a list over the corresponding roi target labels.
      :param batch_gt_boxes: list over batch elements. Each element is a list over the corresponding roi target coordinates.
      :param batch_gt_masks: list over batch elements. Each element is binary mask of shape (n_gt_rois, y, x, (z), c)
      :return: sample_logits: (n_sampled_rois, n_classes) predicted class scores.
      :return: sample_boxes: (n_sampled_rois, n_classes, 2 * dim) predicted corrections to be applied to proposals for refinement.
      :return: sample_mask: (n_sampled_rois, n_classes, y, x, (z)) predicted masks per class and proposal.
      :return: sample_target_class_ids: (n_sampled_rois) target class labels of sampled proposals.
      :return: sample_target_deltas: (n_sampled_rois, 2 * dim) target deltas of sampled proposals for box refinement.
      :return: sample_target_masks: (n_sampled_rois, y, x, (z)) target masks of sampled proposals.
      :return: sample_proposals: (n_sampled_rois, 2 * dim) RPN output for sampled proposals. only for monitoring/plotting.
      """
      # sample rois for loss and get corresponding targets for all Mask R-CNN head network losses.
      (
          sample_ix,
          sample_target_class_ids,
          sample_target_deltas,
          sample_target_mask,
      ) = detection_target_layer(
          self.rpn_rois_batch_info,
          self.batch_mrcnn_class_scores,
          batch_gt_class_ids,
          batch_gt_boxes,
          batch_gt_masks,
          self.cf,
      )
  
      # re-use feature maps and RPN output from first forward pass.
      sample_proposals = self.rpn_rois_batch_info[sample_ix]
      if 0 not in sample_proposals.size():
          sample_logits, sample_boxes = self.classifier(
              self.mrcnn_feature_maps, sample_proposals
          )
          sample_mask = self.mask(
              self.mrcnn_feature_maps, sample_proposals
          )
      else:
          sample_logits = torch.FloatTensor().cuda()
          sample_boxes = torch.FloatTensor().cuda()
          sample_mask = torch.FloatTensor().cuda()
  
      return [
          sample_logits,
          sample_boxes,
          sample_mask,
          sample_target_class_ids,
          sample_target_deltas,
          sample_target_mask,
          sample_proposals,
      ]
  
imports: import utils.model_utils
  import utils.exp_utils
  from cuda_functions.nms_2D.pth_nms import nms_gpu
  from cuda_functions.nms_3D.pth_nms import nms_gpu
  from cuda_functions.roi_align_2D.roi_align.crop_and_resize import CropAndResizeFunction
  from cuda_functions.roi_align_3D.roi_align.crop_and_resize import CropAndResizeFunction
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.utils
label_desc: Use image node_id 6 for calling the net obj's underlying member method code with example usage: obj.loss_samples_forward(batch_gt_class_ids, batch_gt_boxes, batch_gt_masks) and returns: list