docstr: forward pass of the model.
  :param img: input img (b, c, y, x, (z)).
  :return: rpn_pred_logits: (b, n_anchors, 2)
  :return: rpn_pred_deltas: (b, n_anchors, (y, x, (z), log(h), log(w), (log(d))))
  :return: batch_proposal_boxes: (b, n_proposals, (y1, x1, y2, x2, (z1), (z2), batch_ix)) only for monitoring/plotting.
  :return: detections: (n_final_detections, (y1, x1, y2, x2, (z1), (z2), batch_ix, pred_class_id, pred_score)
  :return: detection_masks: (n_final_detections, n_classes, y, x, (z)) raw molded masks as returned by mask-head.
docstr_tok: ["forward","pass","of","the","model",".",":","param","img",":","input","img","(","b",",","c",",","y",",","x",",","(","z",")",")",".",":","return",":","rpn_pred_logits",":","(","b",",","n_anchors",",","2",")",":","return",":","rpn_pred_deltas",":","(","b",",","n_anchors",",","(","y",",","x",",","(","z",")",",","log","(","h",")",",","log","(","w",")",",","(","log","(","d",")",")",")",")",":","return",":","batch_proposal_boxes",":","(","b",",","n_proposals",",","(","y1",",","x1",",","y2",",","x2",",","(","z1",")",",","(","z2",")",",","batch_ix",")",")","only","for","monitoring\/plotting",".",":","return",":","detections",":","(","n_final_detections",",","(","y1",",","x1",",","y2",",","x2",",","(","z1",")",",","(","z2",")",",","batch_ix",",","pred_class_id",",","pred_score",")",":","return",":","detection_masks",":","(","n_final_detections",",","n_classes",",","y",",","x",",","(","z",")",")","raw","molded","masks","as","returned","by","mask-head","."]
code: def forward(self, img):
      """
      forward pass of the model.
      :param img: input img (b, c, y, x, (z)).
      :return: rpn_pred_logits: (b, n_anchors, 2)
      :return: rpn_pred_deltas: (b, n_anchors, (y, x, (z), log(h), log(w), (log(d))))
      :return: batch_proposal_boxes: (b, n_proposals, (y1, x1, y2, x2, (z1), (z2), batch_ix)) only for monitoring/plotting.
      :return: detections: (n_final_detections, (y1, x1, y2, x2, (z1), (z2), batch_ix, pred_class_id, pred_score)
      :return: detection_masks: (n_final_detections, n_classes, y, x, (z)) raw molded masks as returned by mask-head.
      """
      # Feature extraction
      fpn_outs = self.Fpn(img)
      seg_logits = self.final_conv(fpn_outs[0])
      selected_fmaps = [fpn_outs[i + 1] for i in self.cf.pyramid_levels]
  
      # Loop through pyramid layers
      class_layer_outputs, bb_reg_layer_outputs = (
          [],
          [],
      )  # list of lists
      for p in selected_fmaps:
          class_layer_outputs.append(self.Classifier(p))
          bb_reg_layer_outputs.append(self.BBRegressor(p))
  
      # Concatenate layer outputs
      # Convert from list of lists of level outputs to list of lists
      # of outputs across levels.
      # e.g. [[a1, b1, c1], [a2, b2, c2]] => [[a1, a2], [b1, b2], [c1, c2]]
      class_logits = list(zip(*class_layer_outputs))
      class_logits = [torch.cat(list(o), dim=1) for o in class_logits][
          0
      ]
      bb_outputs = list(zip(*bb_reg_layer_outputs))
      bb_outputs = [torch.cat(list(o), dim=1) for o in bb_outputs][0]
  
      # merge batch_dimension and store info in batch_ixs for re-allocation.
      batch_ixs = (
          torch.arange(class_logits.shape[0])
          .unsqueeze(1)
          .repeat(1, class_logits.shape[1])
          .view(-1)
          .cuda()
      )
      flat_class_softmax = F.softmax(
          class_logits.view(-1, class_logits.shape[-1]), 1
      )
      flat_bb_outputs = bb_outputs.view(-1, bb_outputs.shape[-1])
      detections = refine_detections(
          self.anchors,
          flat_class_softmax,
          flat_bb_outputs,
          batch_ixs,
          self.cf,
      )
  
      return detections, class_logits, bb_outputs, seg_logits
  
imports: import utils.model_utils
  import utils.exp_utils
  import sys
  from cuda_functions.nms_2D.pth_nms import nms_gpu
  from cuda_functions.nms_3D.pth_nms import nms_gpu
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.utils
label_desc: Use image node_id 5 for calling the net obj's underlying member method code with example usage: obj.forward(img) and returns: detections,  class_logits,  bb_outputs,  seg_logits