class_docstr: Simplest RoI head, with only two fc layers for classification and
  regression respectively.
class_docstr_tok: ["Simplest","RoI","head",",","with","only","two","fc","layers","for","classification","and","regression","respectively","."]
code: def __init__(
      self,
      with_avg_pool: bool = False,
      with_cls: bool = True,
      with_reg: bool = True,
      roi_feat_size: int = 7,
      in_channels: int = 256,
      num_classes: int = 80,
      bbox_coder: ConfigType = dict(
          type="DeltaXYWHBBoxCoder",
          clip_border=True,
          target_means=[0.0, 0.0, 0.0, 0.0],
          target_stds=[0.1, 0.1, 0.2, 0.2],
      ),
      predict_box_type: str = "hbox",
      reg_class_agnostic: bool = False,
      reg_decoded_bbox: bool = False,
      reg_predictor_cfg: ConfigType = dict(type="Linear"),
      cls_predictor_cfg: ConfigType = dict(type="Linear"),
      loss_cls: ConfigType = dict(
          type="CrossEntropyLoss", use_sigmoid=False, loss_weight=1.0
      ),
      loss_bbox: ConfigType = dict(
          type="SmoothL1Loss", beta=1.0, loss_weight=1.0
      ),
      init_cfg: OptMultiConfig = None,
  ) -> None:
      super().__init__(init_cfg=init_cfg)
      assert with_cls or with_reg
      self.with_avg_pool = with_avg_pool
      self.with_cls = with_cls
      self.with_reg = with_reg
      self.roi_feat_size = _pair(roi_feat_size)
      self.roi_feat_area = self.roi_feat_size[0] * self.roi_feat_size[1]
      self.in_channels = in_channels
      self.num_classes = num_classes
      self.predict_box_type = predict_box_type
      self.reg_class_agnostic = reg_class_agnostic
      self.reg_decoded_bbox = reg_decoded_bbox
      self.reg_predictor_cfg = reg_predictor_cfg
      self.cls_predictor_cfg = cls_predictor_cfg
  
      self.bbox_coder = TASK_UTILS.build(bbox_coder)
      self.loss_cls = MODELS.build(loss_cls)
      self.loss_bbox = MODELS.build(loss_bbox)
  
      in_channels = self.in_channels
      if self.with_avg_pool:
          self.avg_pool = nn.AvgPool2d(self.roi_feat_size)
      else:
          in_channels *= self.roi_feat_area
      if self.with_cls:
          # need to add background class
          if self.custom_cls_channels:
              cls_channels = self.loss_cls.get_cls_channels(
                  self.num_classes
              )
          else:
              cls_channels = num_classes + 1
          cls_predictor_cfg_ = self.cls_predictor_cfg.copy()
          cls_predictor_cfg_.update(
              in_features=in_channels, out_features=cls_channels
          )
          self.fc_cls = MODELS.build(cls_predictor_cfg_)
      if self.with_reg:
          box_dim = self.bbox_coder.encode_size
          out_dim_reg = (
              box_dim if reg_class_agnostic else box_dim * num_classes
          )
          reg_predictor_cfg_ = self.reg_predictor_cfg.copy()
          if isinstance(reg_predictor_cfg_, (dict, ConfigDict)):
              reg_predictor_cfg_.update(
                  in_features=in_channels, out_features=out_dim_reg
              )
          self.fc_reg = MODELS.build(reg_predictor_cfg_)
      self.debug_imgs = None
      if init_cfg is None:
          self.init_cfg = []
          if self.with_cls:
              self.init_cfg += [
                  dict(
                      type="Normal",
                      std=0.01,
                      override=dict(name="fc_cls"),
                  )
              ]
          if self.with_reg:
              self.init_cfg += [
                  dict(
                      type="Normal",
                      std=0.001,
                      override=dict(name="fc_reg"),
                  )
              ]
  
imports: from typing import List, Optional, Tuple, Union
  import torch
  import torch.nn
  import torch.nn.functional
  from mmengine.config import ConfigDict
  from mmengine.model import BaseModule
  from mmengine.structures import InstanceData
  from torch import Tensor
  from torch.nn.modules.utils import _pair
  from mmdet.models.layers import multiclass_nms
  from mmdet.models.losses import accuracy
  from mmdet.models.task_modules.samplers import SamplingResult
  from mmdet.models.utils import empty_instances, multi_apply
  from mmdet.registry import MODELS, TASK_UTILS
  from mmdet.structures.bbox import get_box_tensor, scale_boxes
  from mmdet.utils import ConfigType, InstanceList, OptMultiConfig
label_desc: Use image node_id 1 to create a new BBoxHead object from inherited base classes: BaseModule with example: obj = BBoxHead(with_avg_pool, with_cls, with_reg, roi_feat_size, in_channels, num_classes, bbox_coder, predict_box_type, reg_class_agnostic, reg_decoded_bbox, reg_predictor_cfg, cls_predictor_cfg, loss_cls, loss_bbox, init_cfg)