docstr: Arguments:
      in_channels (int): number of channels of the input feature
docstr_tok: ["Arguments",":","in_channels","(","int",")",":","number","of","channels","of","the","input","feature"]
code: def __init__(self, cfg, input_shape: List[ShapeSpec]):
      """
      Arguments:
          in_channels (int): number of channels of the input feature
      """
      super().__init__()
      # TODO: Implement the sigmoid version first.
      self.num_classes = cfg.CONFIG.MODEL.DIRECTPOSE.NUM_CLASSES
      self.num_kpts = cfg.CONFIG.MODEL.DIRECTPOSE.NUM_KPTS
      self.fpn_strides = cfg.CONFIG.MODEL.DIRECTPOSE.FPN_STRIDES
      self.hm_loss_type = cfg.CONFIG.MODEL.DIRECTPOSE.HM_LOSS_TYPE
      self.sample_feature = cfg.CONFIG.MODEL.DIRECTPOSE.SAMPLE_FEATURE
      self.groups = cfg.CONFIG.MODEL.DIRECTPOSE.KPALIGN_GROUPS
      self.seperate_conv_feature = (
          cfg.CONFIG.MODEL.DIRECTPOSE.SEPERATE_CONV_FEATURE
      )
      self.seperate_conv_channel = (
          cfg.CONFIG.MODEL.DIRECTPOSE.SEPERATE_CONV_CHANNEL
      )
      self.enable_bbox_branch = (
          cfg.CONFIG.MODEL.DIRECTPOSE.ENABLE_BBOX_BRANCH
      )
      self.hm_channels = cfg.CONFIG.MODEL.DIRECTPOSE.HM_CHANNELS
      self.loss_on_locator = cfg.CONFIG.MODEL.DIRECTPOSE.LOSS_ON_LOCATOR
      self.predict_hm_offset = cfg.CONFIG.MODEL.DIRECTPOSE.HM_OFFSET
      self.enable_kpt_vis_branch = cfg.CONFIG.MODEL.DIRECTPOSE.KPT_VIS
      self.enable_hm_branch = (
          cfg.CONFIG.MODEL.DIRECTPOSE.ENABLE_HM_BRANCH
      )
      self.center_branch = cfg.CONFIG.MODEL.DIRECTPOSE.CENTER_BRANCH
      self.kpt_per_group = [5, 1, 2, 1, 2, 1, 2, 1, 2]
      self.kpt_index = torch.tensor(
          [0, 1, 2, 3, 4, 5, 8, 6, 9, 7, 10, 11, 14, 12, 15, 13, 16]
      )
  
      head_configs = {
          "cls": (
              cfg.CONFIG.MODEL.DIRECTPOSE.NUM_CLS_CONVS,
              cfg.CONFIG.MODEL.DIRECTPOSE.USE_DEFORMABLE,
          ),
          "kpt": (
              cfg.CONFIG.MODEL.DIRECTPOSE.NUM_KPT_CONVS,
              cfg.CONFIG.MODEL.DIRECTPOSE.USE_DEFORMABLE,
          ),
          "share": (cfg.CONFIG.MODEL.DIRECTPOSE.NUM_SHARE_CONVS, False),
      }
      if self.enable_bbox_branch:
          head_configs["bbox"] = (
              cfg.CONFIG.MODEL.DIRECTPOSE.NUM_BOX_CONVS,
              cfg.CONFIG.MODEL.DIRECTPOSE.USE_DEFORMABLE,
          )
      if self.enable_hm_branch:
          head_configs["hm"] = (
              cfg.CONFIG.MODEL.DIRECTPOSE.NUM_HMS_CONVS,
              cfg.CONFIG.MODEL.DIRECTPOSE.USE_DEFORMABLE,
          )
  
      norm = (
          None
          if cfg.CONFIG.MODEL.DIRECTPOSE.NORM == "none"
          else cfg.CONFIG.MODEL.DIRECTPOSE.NORM
      )
      self.num_levels = len(input_shape)
  
      in_channels = [s.channels for s in input_shape]
      assert (
          len(set(in_channels)) == 1
      ), "Each level must have the same channel!"
      in_channels = in_channels[0]
      self.in_channels_to_top_module = in_channels
  
      for head in head_configs:
          tower = []
          num_convs, use_deformable = head_configs[head]
          # pylint: disable=no-else-raise
          for i in range(num_convs):
              if use_deformable and i == num_convs - 1:
                  raise NotImplementedError(
                      "Deformable Conv v2 is not supported yet!"
                  )
                  # conv_func = DFConv2d
              else:
                  conv_func = nn.Conv2d
  
              in_channels = self.in_channels_to_top_module
              out_channels = in_channels
              groups = 1
              num_groups_gn = 32
  
              if head == "hm":
                  in_channels = (
                      self.in_channels_to_top_module
                      if i == 0
                      else self.hm_channels
                  )
                  out_channels = self.hm_channels
              elif head == "kpt" and self.seperate_conv_feature:
                  in_channels = (
                      self.in_channels_to_top_module
                      if i == 0
                      else self.seperate_conv_channel * self.groups
                  )
                  out_channels = (
                      self.seperate_conv_channel * self.groups
                  )
                  groups = 1 if i == 0 else self.groups
                  num_groups_gn = out_channels // 4
  
              tower.append(
                  conv_func(
                      in_channels,
                      out_channels,
                      kernel_size=3,
                      stride=1,
                      padding=1,
                      bias=True,
                      groups=groups,
                  )
              )
              if norm == "GN":
                  tower.append(
                      nn.GroupNorm(num_groups_gn, out_channels)
                  )
              elif norm == "NaiveGN":
                  tower.append(
                      NaiveGroupNorm(num_groups_gn, out_channels)
                  )
              elif norm == "BN":
                  tower.append(
                      ModuleListDial(
                          [
                              nn.BatchNorm2d(out_channels)
                              for _ in range(self.num_levels)
                          ]
                      )
                  )
              elif norm == "SyncBN":
                  tower.append(
                      ModuleListDial(
                          [
                              NaiveSyncBatchNorm(out_channels)
                              for _ in range(self.num_levels)
                          ]
                      )
                  )
              tower.append(nn.ReLU())
          self.add_module(
              "{}_tower".format(head), nn.Sequential(*tower)
          )
  
      in_channels = self.in_channels_to_top_module
  
      self.cls_logits = nn.Conv2d(
          in_channels,
          self.num_classes,
          kernel_size=3,
          stride=1,
          padding=1,
      )
  
      if self.enable_bbox_branch:
          self.bbox_pred = nn.Conv2d(
              in_channels, 4, kernel_size=3, stride=1, padding=1
          )
  
      if self.seperate_conv_feature:
          kpalign_inchannel = self.seperate_conv_channel * self.groups
          conv_groups = self.groups
          num_groups_gn = kpalign_inchannel // 4
      else:
          kpalign_inchannel = in_channels
          conv_groups = 1
          num_groups_gn = 32
  
      ctrness_inchannel = (
          kpalign_inchannel
          if self.center_branch == "kpt"
          else in_channels
      )
      self.ctrness = nn.Conv2d(
          ctrness_inchannel, 1, kernel_size=3, stride=1, padding=1
      )
  
      self.locator = nn.Conv2d(
          kpalign_inchannel,
          2 * self.groups,
          kernel_size=3,
          stride=1,
          padding=1,
          groups=conv_groups,
      )
      self.sampler = nn.Sequential(
          nn.Conv2d(
              kpalign_inchannel,
              kpalign_inchannel,
              kernel_size=3,
              stride=1,
              padding=1,
              groups=conv_groups,
          ),
          nn.GroupNorm(num_groups_gn, kpalign_inchannel),
          nn.ReLU(),
      )
      self.predictor = nn.ModuleList()
      for g in self.kpt_per_group:
          self.predictor.append(
              Predictor(
                  self.seperate_conv_channel,
                  g,
                  self.enable_kpt_vis_branch,
              )
          )
  
      if self.enable_hm_branch:
          self.hm_pred = nn.Conv2d(
              self.hm_channels,
              self.num_kpts,
              kernel_size=3,
              stride=1,
              padding=1,
          )
          if self.predict_hm_offset:
              self.hm_offset_pred = nn.Conv2d(
                  self.hm_channels,
                  2,
                  kernel_size=3,
                  stride=1,
                  padding=1,
              )
  
      if cfg.CONFIG.MODEL.DIRECTPOSE.USE_SCALE:
          self.scales = nn.ModuleList(
              [Scale(init_value=1.0) for _ in range(self.num_levels)]
          )
      else:
          self.scales = None
  
      all_modules = [
          self.cls_tower,
          self.share_tower,
          self.kpt_tower,
          self.cls_logits,
          self.ctrness,
          self.locator,
          self.sampler,
          self.predictor,
      ]
      if self.enable_bbox_branch:
          all_modules.append(self.bbox_tower)
          all_modules.append(self.bbox_pred)
      if self.enable_hm_branch:
          all_modules.append(self.hm_tower)
          all_modules.append(self.hm_pred)
          if self.predict_hm_offset:
              all_modules.append(self.hm_offset_pred)
  
      for modules in all_modules:
          for l in modules.modules():
              if isinstance(l, nn.Conv2d):
                  torch.nn.init.normal_(l.weight, std=0.01)
                  torch.nn.init.constant_(l.bias, 0)
  
      # initialize the bias for focal loss
      prior_prob = cfg.CONFIG.MODEL.DIRECTPOSE.PRIOR_PROB
      bias_value = -math.log((1 - prior_prob) / prior_prob)
      torch.nn.init.constant_(self.cls_logits.bias, bias_value)
  
      if self.enable_hm_branch and self.hm_loss_type == "focal":
          torch.nn.init.constant_(self.hm_pred.bias, bias_value)
  
imports: import math
  from typing import List, Dict
  import torch
  from torch import nn
  from torch.nn import functional
  from torch.autograd import Variable
  import numpy
  from ...utils.comm import compute_locations
  from ...nn.shape_spec import ShapeSpec
  from ...nn.batch_norm import NaiveSyncBatchNorm
  from ...nn.deform_conv import DeformConvWithChangeableStride
  from ...nn.group_norm import NaiveGroupNorm
  from .directpose_outputs import DirectPoseOutputs
label_desc: Use image node_id 1 to create a new DIRECTPOSEHead object from inherited base classes: nn with example: obj = DIRECTPOSEHead(cfg, input_shape)