docstr: Darknet, see https://pjreddie.com/darknet/yolo/
  
  Args:
      depth (int): depth of network
      freeze_at (int): freeze the backbone at which stage
      filter_size (int): filter size, default 3
      return_idx (list): index of stages whose feature maps are returned
      norm_type (str): batch norm type, default bn
      norm_decay (str): decay for weight and bias of batch norm layer, default 0.
      data_format (str): data format, NCHW or NHWC
docstr_tok: ["Darknet",",","see","https",":","\/\/pjreddie.com\/darknet\/yolo\/","Args",":","depth","(","int",")",":","depth","of","network","freeze_at","(","int",")",":","freeze","the","backbone","at","which","stage","filter_size","(","int",")",":","filter","size",",","default","3","return_idx","(","list",")",":","index","of","stages","whose","feature","maps","are","returned","norm_type","(","str",")",":","batch","norm","type",",","default","bn","norm_decay","(","str",")",":","decay","for","weight","and","bias","of","batch","norm","layer",",","default","0.","data_format","(","str",")",":","data","format",",","NCHW","or","NHWC"]
code: def __init__(
      self,
      depth=53,
      freeze_at=-1,
      return_idx=[2, 3, 4],
      num_stages=5,
      norm_type="bn",
      norm_decay=0.0,
      freeze_norm=False,
      data_format="NCHW",
  ):
      """
      Darknet, see https://pjreddie.com/darknet/yolo/
  
      Args:
          depth (int): depth of network
          freeze_at (int): freeze the backbone at which stage
          filter_size (int): filter size, default 3
          return_idx (list): index of stages whose feature maps are returned
          norm_type (str): batch norm type, default bn
          norm_decay (str): decay for weight and bias of batch norm layer, default 0.
          data_format (str): data format, NCHW or NHWC
      """
      super(DarkNet, self).__init__()
      self.depth = depth
      self.freeze_at = freeze_at
      self.return_idx = return_idx
      self.num_stages = num_stages
      self.stages = DarkNet_cfg[self.depth][0:num_stages]
  
      self.conv0 = ConvBNLayer(
          ch_in=3,
          ch_out=32,
          filter_size=3,
          stride=1,
          padding=1,
          norm_type=norm_type,
          norm_decay=norm_decay,
          freeze_norm=freeze_norm,
          data_format=data_format,
      )
  
      self.downsample0 = DownSample(
          ch_in=32,
          ch_out=32 * 2,
          norm_type=norm_type,
          norm_decay=norm_decay,
          freeze_norm=freeze_norm,
          data_format=data_format,
      )
  
      self._out_channels = []
      self.darknet_conv_block_list = []
      self.downsample_list = []
      ch_in = [64, 128, 256, 512, 1024]
      for i, stage in enumerate(self.stages):
          name = "stage.{}".format(i)
          conv_block = self.add_sublayer(
              name,
              Blocks(
                  int(ch_in[i]),
                  int(ch_in[i]),
                  stage,
                  norm_type=norm_type,
                  norm_decay=norm_decay,
                  freeze_norm=freeze_norm,
                  data_format=data_format,
                  name=name,
              ),
          )
          self.darknet_conv_block_list.append(conv_block)
          if i in return_idx:
              self._out_channels.append(int(ch_in[i]))
      for i in range(num_stages - 1):
          down_name = "stage.{}.downsample".format(i)
          downsample = self.add_sublayer(
              down_name,
              DownSample(
                  ch_in=int(ch_in[i]),
                  ch_out=int(ch_in[i + 1]),
                  norm_type=norm_type,
                  norm_decay=norm_decay,
                  freeze_norm=freeze_norm,
                  data_format=data_format,
              ),
          )
          self.downsample_list.append(downsample)
  
imports: import paddle
  import paddle.nn
  import paddle.nn.functional
  from ppdet.core.workspace import register, serializable
  from ppdet.modeling.ops import batch_norm, mish
  from ..shape_spec import ShapeSpec
label_desc: Use image node_id 1 to create a new DarkNet object from inherited base classes: nn with example: obj = DarkNet(depth, freeze_at, return_idx, num_stages, norm_type, norm_decay, freeze_norm, data_format)