docstr: Dense Convolutional Block.
  
  References:
      Huang, Gao, et al. "Densely connected convolutional networks."
      Proceedings of the IEEE conference on computer vision and
      pattern recognition. 2017.
  
  Args:
      num_features: number of internal channels used for the layer
      in_channels: number of the input channels.
      out_channels: number of the output channels.
      dropout_prob: dropout rate after each dense layer.
      act: activation type and arguments. Defaults to relu.
      norm: feature normalization type and arguments. Defaults to batch norm.
      drop_first_norm_relu - omits the first norm/relu for the first layer
      kernel_size: size of the kernel for >1 convolutions (dependent on mode)
docstr_tok: ["Dense","Convolutional","Block",".","References",":","Huang",",","Gao",",","et","al",".","``","Densely","connected","convolutional","networks",".","''","Proceedings","of","the","IEEE","conference","on","computer","vision","and","pattern","recognition",".","2017",".","Args",":","num_features",":","number","of","internal","channels","used","for","the","layer","in_channels",":","number","of","the","input","channels",".","out_channels",":","number","of","the","output","channels",".","dropout_prob",":","dropout","rate","after","each","dense","layer",".","act",":","activation","type","and","arguments",".","Defaults","to","relu",".","norm",":","feature","normalization","type","and","arguments",".","Defaults","to","batch","norm",".","drop_first_norm_relu","-","omits","the","first","norm\/relu","for","the","first","layer","kernel_size",":","size","of","the","kernel","for",">","1","convolutions","(","dependent","on","mode",")"]
code: def __init__(
      self,
      num_features: int,
      in_channels: int,
      out_channels: int,
      dropout_prob: float = 0.0,
      act: str | tuple = ("relu", {"inplace": True}),
      norm: str | tuple = "batch",
      drop_first_norm_relu: int = 0,
      kernel_size: int = 3,
  ) -> None:
      """Dense Convolutional Block.
  
      References:
          Huang, Gao, et al. "Densely connected convolutional networks."
          Proceedings of the IEEE conference on computer vision and
          pattern recognition. 2017.
  
      Args:
          num_features: number of internal channels used for the layer
          in_channels: number of the input channels.
          out_channels: number of the output channels.
          dropout_prob: dropout rate after each dense layer.
          act: activation type and arguments. Defaults to relu.
          norm: feature normalization type and arguments. Defaults to batch norm.
          drop_first_norm_relu - omits the first norm/relu for the first layer
          kernel_size: size of the kernel for >1 convolutions (dependent on mode)
      """
      super().__init__()
  
      self.layers = nn.Sequential()
      conv_type: Callable = Conv[Conv.CONV, 2]
      dropout_type: Callable = Dropout[Dropout.DROPOUT, 2]
  
      if not drop_first_norm_relu:
          self.layers.add_module(
              "preact/bn",
              get_norm_layer(
                  name=norm, spatial_dims=2, channels=in_channels
              ),
          )
          self.layers.add_module("preact/relu", get_act_layer(name=act))
  
      self.layers.add_module(
          "conv1",
          conv_type(
              in_channels,
              num_features,
              kernel_size=1,
              padding=0,
              bias=False,
          ),
      )
      self.layers.add_module(
          "conv1/bn",
          get_norm_layer(
              name=norm, spatial_dims=2, channels=num_features
          ),
      )
      self.layers.add_module("conv1/relu", get_act_layer(name=act))
  
      if in_channels != 64 and drop_first_norm_relu:
          self.layers.add_module(
              "conv2",
              conv_type(
                  num_features,
                  num_features,
                  kernel_size=kernel_size,
                  stride=2,
                  padding=2,
                  bias=False,
              ),
          )
      else:
          self.layers.add_module(
              "conv2",
              conv_type(
                  num_features,
                  num_features,
                  kernel_size=kernel_size,
                  padding=1,
                  bias=False,
              ),
          )
  
      self.layers.add_module(
          "conv2/bn",
          get_norm_layer(
              name=norm, spatial_dims=2, channels=num_features
          ),
      )
      self.layers.add_module("conv2/relu", get_act_layer(name=act))
      self.layers.add_module(
          "conv3",
          conv_type(
              num_features,
              out_channels,
              kernel_size=1,
              padding=0,
              bias=False,
          ),
      )
  
      if dropout_prob > 0:
          self.layers.add_module("dropout", dropout_type(dropout_prob))
  
imports: from __future__ import annotations
  import os
  import re
  import warnings
  from collections import OrderedDict
  from collections.abc import Callable, Sequence
  import torch
  import torch.nn
  from monai.apps.utils import download_url
  from monai.networks.blocks import UpSample
  from monai.networks.layers.factories import Conv, Dropout
  from monai.networks.layers.utils import get_act_layer, get_norm_layer
  from monai.utils.enums import HoVerNetBranch, HoVerNetMode, InterpolateMode, UpsampleMode
  from monai.utils.module import export, look_up_option
label_desc: Use image node_id 1 to create a new _DenseLayer object from inherited base classes: nn with example: obj = _DenseLayer(num_features, in_channels, out_channels, dropout_prob, act, norm, drop_first_norm_relu, kernel_size)