code: def predict_proposals(
      self,
      logits_pred,
      bbox_reg_pred,
      kpt_reg_pred,
      ctrness_pred,
      hms,
      hms_offset,
      locations,
      image_sizes,
      top_feats=None,
      images=None,
  ):
      if self.training:
          self.pre_nms_thresh = self.pre_nms_thresh_train
          self.pre_nms_topk = self.pre_nms_topk_train
          self.post_nms_topk = self.post_nms_topk_train
      else:
          self.pre_nms_thresh = self.pre_nms_thresh_test
          self.pre_nms_topk = self.pre_nms_topk_test
          self.post_nms_topk = self.post_nms_topk_test
  
      sampled_boxes = []
  
      bundle = {
          "l": locations,
          "o": logits_pred,
          "c": ctrness_pred,
          "kr": kpt_reg_pred,
          "s": self.strides,
      }
      if self.enable_bbox_branch:
          bundle["r"] = bbox_reg_pred
      if len(top_feats) > 0:
          bundle["t"] = top_feats
  
      if self._tvm_mode and not self.training:
          forward_for_single_feature_map_func = (
              self.forward_for_single_feature_map_tvm
          )
      else:
          forward_for_single_feature_map_func = (
              self.forward_for_single_feature_map
          )
  
      for i, per_bundle in enumerate(zip(*bundle.values())):
          # get per-level bundle
          per_bundle = dict(zip(bundle.keys(), per_bundle))
          # recall that during training, we normalize regression targets with FPN's stride.
          # we denormalize them here.
          l = per_bundle["l"]
          o = per_bundle["o"]
          r = (
              per_bundle["r"] * per_bundle["s"]
              if "r" in bundle
              else None
          )
          if self.enable_kpt_vis_branch:
              b, _, h, w = per_bundle["kr"].shape
              kr_reshape = per_bundle["kr"].reshape(
                  b, self.num_kpts, 3, h, w
              )
              kr = (
                  kr_reshape[:, :, 0:2, :, :].reshape(b, -1, h, w)
                  * per_bundle["s"]
              )
              kr_vis = kr_reshape[:, :, 2, :, :]
          else:
              kr = per_bundle["kr"] * per_bundle["s"]
              kr_vis = None
          c = per_bundle["c"]
          t = per_bundle["t"] if "t" in bundle else None
  
          # DEBUG:
          # sampled_boxes.append((l, o, r, kr, kr_vis))
          # continue
  
          sampled_boxes.append(
              forward_for_single_feature_map_func(
                  l, o, r, kr, kr_vis, c, image_sizes, t
              )
          )
  
          for per_im_sampled_boxes in sampled_boxes[-1]:
              per_im_sampled_boxes.fpn_levels = (
                  l.new_ones(
                      len(per_im_sampled_boxes), dtype=torch.long
                  )
                  * i
              )
  
      boxlists = list(zip(*sampled_boxes))
      # ret = [Instances.cat(boxlist) for boxlist in boxlists]
      # output = [x.pred_boxes.tensor for x in ret] + [x.pred_keypoints for x in ret]
      # return output
      # boxlists = [Instances.cat(boxlist) for boxlist in boxlists]
      # boxlists = [self.select_over_all_level(Instances.cat(boxlist)) for boxlist in boxlists]
      boxlists = [Instances.cat(boxlist) for boxlist in boxlists]
  
      if self._tvm_mode and not self.training:
          pred_boxes = [
              boxlist.pred_boxes.tensor for boxlist in boxlists
          ]
          pred_keypoints = [
              boxlist.pred_keypoints for boxlist in boxlists
          ]
          pred_scores = [boxlist.scores for boxlist in boxlists]
          pred_ids = [boxlist.pred_classes for boxlist in boxlists]
          assert len(pred_ids) == 1, "tvm supports bs==1 only"
          if self.enable_hm_branch and self.combine_hm_and_kpt:
              pred_keypoints = self._refine_kpt(
                  pred_boxes,
                  pred_keypoints,
                  hms,
                  hms_offset,
                  images,
                  topk=40,
                  thresh=0.1,
              )
          # nms_input = torch.cat((, torch.arange(end=int(pred_boxes[0].shape[0])).to(pred_boxes[0].device).unsqueeze(-1)), dim=1)
          # print(nms_input.shape)
          nms_ret = nms(pred_boxes[0], pred_scores[0], self.nms_thresh)
          return (
              pred_ids[0],
              nms_ret,
              pred_boxes[0],
              pred_scores[0],
              pred_keypoints[0],
          )
  
      boxlists = self.select_over_all_levels(boxlists)
      if self.enable_hm_branch and self.combine_hm_and_kpt:
          boxlists = self.refine_kpt(
              boxlists, hms, hms_offset, images, topk=40, thresh=0.1
          )
      # visualize_kpt_offset(images, boxlists, vis_dir=self.vis_res_dir, cnt=self.cnt)
      # self.cnt += 1
      return boxlists
  
imports: import logging
  import os
  from typing import List
  import numpy
  import torch
  from torch import nn
  import torch.nn.functional
  from torchvision.ops import nms
  from ...data.structures import Instances, Boxes
  from ...utils.comm import get_world_size
  from ...nn.focal_loss import sigmoid_focal_loss_jit
  from ...nn.smooth_l1_loss import smooth_l1_loss
  from ...utils.comm import reduce_sum
  from ...nn.nms import ml_nms, oks_nms, close_kpt_nms
  from ...nn.iou_loss import IOULoss
  from ...nn.keypoint_loss import WeightedMSELoss, HMFocalLoss
label_desc: Use image node_id 8 for calling the DirectPoseOutputs obj's underlying member method code with example usage: obj.predict_proposals(logits_pred, bbox_reg_pred, kpt_reg_pred, ctrness_pred, hms, hms_offset, locations, image_sizes, top_feats, images) and returns: boxlists, pred_ids,  nms_ret,  pred_boxes,  pred_scores,  pred_keypoints