code: def __init__(self, cfg):
      super(DirectPoseOutputs, self).__init__()
  
      self.focal_loss_alpha = cfg.CONFIG.MODEL.DIRECTPOSE.LOSS_ALPHA
      self.focal_loss_gamma = cfg.CONFIG.MODEL.DIRECTPOSE.LOSS_GAMMA
      self.center_sample = cfg.CONFIG.MODEL.DIRECTPOSE.CENTER_SAMPLE
      self.radius = cfg.CONFIG.MODEL.DIRECTPOSE.POS_RADIUS
      self.pre_nms_thresh_train = (
          cfg.CONFIG.MODEL.DIRECTPOSE.INFERENCE_TH_TRAIN
      )
      self.pre_nms_topk_train = (
          cfg.CONFIG.MODEL.DIRECTPOSE.PRE_NMS_TOPK_TRAIN
      )
      self.post_nms_topk_train = (
          cfg.CONFIG.MODEL.DIRECTPOSE.POST_NMS_TOPK_TRAIN
      )
      self.loc_loss_func = IOULoss(
          cfg.CONFIG.MODEL.DIRECTPOSE.LOC_LOSS_TYPE
      )
      self.kpt_l1_beta = cfg.CONFIG.MODEL.DIRECTPOSE.KPT_L1_beta
      self.enable_bbox_branch = (
          cfg.CONFIG.MODEL.DIRECTPOSE.ENABLE_BBOX_BRANCH
      )
      self.loss_on_locator = cfg.CONFIG.MODEL.DIRECTPOSE.LOSS_ON_LOCATOR
      self.enable_kpt_vis_branch = cfg.CONFIG.MODEL.DIRECTPOSE.KPT_VIS
      self.enable_close_kpt_nms = (
          cfg.CONFIG.MODEL.DIRECTPOSE.CLOSEKPT_NMS
      )
      # self.vis_res_dir = os.path.join('/workplace/data/motion_efs/home/manchenw/AdelaiDet/visualization',
      #                                 cfg.CONFIG.MODEL.WEIGHTS.split('/')[2])
  
      self.enable_hm_branch = (
          cfg.CONFIG.MODEL.DIRECTPOSE.ENABLE_HM_BRANCH
      )
      self.hm_type = cfg.CONFIG.MODEL.DIRECTPOSE.HM_TYPE
      self.predict_hm_offset = cfg.CONFIG.MODEL.DIRECTPOSE.HM_OFFSET
      self.hm_loss_type = cfg.CONFIG.MODEL.DIRECTPOSE.HM_LOSS_TYPE
      self.combine_hm_and_kpt = cfg.CONFIG.MODEL.DIRECTPOSE.REFINE_KPT
      self.hm_loss_weight = cfg.CONFIG.MODEL.DIRECTPOSE.HM_LOSS_WEIGHT
      self.g = self.get_gaussian_kernel(sigma=2)
      if self.hm_type == "Gaussian":
          if self.hm_loss_type == "mse":
              self.hm_bg_weight = (
                  cfg.CONFIG.MODEL.DIRECTPOSE.HM_MSELOSS_BG_WEIGHT
              )
              self.hm_loss_weight = (
                  cfg.CONFIG.MODEL.DIRECTPOSE.HM_MSELOSS_WEIGHT
              )
              self.hm_loss = WeightedMSELoss()
          elif self.hm_loss_type == "focal":
              self.hm_bg_weight = 1.0
              hm_focal_alpha = (
                  cfg.CONFIG.MODEL.DIRECTPOSE.HM_FOCALLOSS_ALPHA
              )
              hm_focal_beta = (
                  cfg.CONFIG.MODEL.DIRECTPOSE.HM_FOCALLOSS_BETA
              )
              self.hm_loss = HMFocalLoss(hm_focal_alpha, hm_focal_beta)
  
      self.pre_nms_thresh_test = (
          cfg.CONFIG.MODEL.DIRECTPOSE.INFERENCE_TH_TEST
      )
      self.pre_nms_topk_test = (
          cfg.CONFIG.MODEL.DIRECTPOSE.PRE_NMS_TOPK_TEST
      )
      self.post_nms_topk_test = (
          cfg.CONFIG.MODEL.DIRECTPOSE.POST_NMS_TOPK_TEST
      )
      self.nms_thresh = cfg.CONFIG.MODEL.DIRECTPOSE.NMS_TH
      self.thresh_with_ctr = cfg.CONFIG.MODEL.DIRECTPOSE.THRESH_WITH_CTR
  
      self.num_classes = cfg.CONFIG.MODEL.DIRECTPOSE.NUM_CLASSES
      self.strides = cfg.CONFIG.MODEL.DIRECTPOSE.FPN_STRIDES
      self.num_kpts = cfg.CONFIG.MODEL.DIRECTPOSE.NUM_KPTS
  
      # generate sizes of interest
      soi = []
      prev_size = -1
      for s in cfg.CONFIG.MODEL.DIRECTPOSE.SIZES_OF_INTEREST:
          soi.append([prev_size, s])
          prev_size = s
      soi.append([prev_size, INF])
      self.sizes_of_interest = soi
      self.cnt = 0
      # TVM MODE
      self._tvm_mode = cfg.CONFIG.MODEL.TVM_MODE
  
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 1 to create a new DirectPoseOutputs object from inherited base classes: nn with example: obj = DirectPoseOutputs(cfg)