class_docstr: Detection Head of `YOLOF <https://arxiv.org/abs/2103.09460>`_
  
  Args:
      num_classes (int): The number of object classes (w/o background)
      in_channels (list[int]): The number of input channels per scale.
      cls_num_convs (int): The number of convolutions of cls branch.
         Defaults to 2.
      reg_num_convs (int): The number of convolutions of reg branch.
         Defaults to 4.
      norm_cfg (:obj:`ConfigDict` or dict): Config dict for normalization
          layer. Defaults to ``dict(type='BN', requires_grad=True)``.
class_docstr_tok: ["Detection","Head","of","`","YOLOF","<","https",":","\/\/arxiv.org\/abs\/2103.09460",">","`","_","Args",":","num_classes","(","int",")",":","The","number","of","object","classes","(","w\/o","background",")","in_channels","(","list","[","int","]",")",":","The","number","of","input","channels","per","scale",".","cls_num_convs","(","int",")",":","The","number","of","convolutions","of","cls","branch",".","Defaults","to","2.","reg_num_convs","(","int",")",":","The","number","of","convolutions","of","reg","branch",".","Defaults","to","4.","norm_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","dict","for","normalization","layer",".","Defaults","to","``","dict","(","type='BN","'",",","requires_grad=True",")","``","."]
docstr: Forward feature of a single scale level.
  
  Args:
      x (Tensor): Features of a single scale level.
  
  Returns:
      tuple:
          normalized_cls_score (Tensor): Normalized Cls scores for a                     single scale level, the channels number is                     num_base_priors * num_classes.
          bbox_reg (Tensor): Box energies / deltas for a single scale                     level, the channels number is num_base_priors * 4.
docstr_tok: ["Forward","feature","of","a","single","scale","level",".","Args",":","x","(","Tensor",")",":","Features","of","a","single","scale","level",".","Returns",":","tuple",":","normalized_cls_score","(","Tensor",")",":","Normalized","Cls","scores","for","a","single","scale","level",",","the","channels","number","is","num_base_priors","*","num_classes",".","bbox_reg","(","Tensor",")",":","Box","energies","\/","deltas","for","a","single","scale","level",",","the","channels","number","is","num_base_priors","*","4","."]
code: def forward_single(self, x: Tensor) -> Tuple[Tensor, Tensor]:
      """Forward feature of a single scale level.
  
          Args:
              x (Tensor): Features of a single scale level.
  
          Returns:
              tuple:
                  normalized_cls_score (Tensor): Normalized Cls scores for a \
                      single scale level, the channels number is \
                      num_base_priors * num_classes.
                  bbox_reg (Tensor): Box energies / deltas for a single scale \
                      level, the channels number is num_base_priors * 4.
          """
      cls_score = self.cls_score(self.cls_subnet(x))
      N, _, H, W = cls_score.shape
      cls_score = cls_score.view(N, -1, self.num_classes, H, W)
  
      reg_feat = self.bbox_subnet(x)
      bbox_reg = self.bbox_pred(reg_feat)
      objectness = self.object_pred(reg_feat)
  
      # implicit objectness
      objectness = objectness.view(N, -1, 1, H, W)
      normalized_cls_score = (
          cls_score
          + objectness
          - torch.log(
              1.0
              + torch.clamp(cls_score.exp(), max=INF)
              + torch.clamp(objectness.exp(), max=INF)
          )
      )
      normalized_cls_score = normalized_cls_score.view(N, -1, H, W)
      return normalized_cls_score, bbox_reg
  
imports: from typing import List, Optional, Tuple
  import torch
  import torch.nn
  from mmcv.cnn import ConvModule, is_norm
  from mmengine.model import bias_init_with_prob, constant_init, normal_init
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.registry import MODELS
  from mmdet.utils import ConfigType, InstanceList, OptInstanceList, reduce_mean
  from ..task_modules.prior_generators import anchor_inside_flags
  from ..utils import levels_to_images, multi_apply, unmap
  from .anchor_head import AnchorHead
label_desc: Use image node_id 4 for calling the YOLOFHead obj's underlying member method code with example usage: obj.forward_single(x) and returns: normalized_cls_score,  bbox_reg