class_docstr: Densenet based on: `Densely Connected Convolutional Networks <https://arxiv.org/pdf/1608.06993.pdf>`_.
  Adapted from PyTorch Hub 2D version: https://pytorch.org/vision/stable/models.html#id16.
  This network is non-deterministic When `spatial_dims` is 3 and CUDA is enabled. Please check the link below
  for more details:
  https://pytorch.org/docs/stable/generated/torch.use_deterministic_algorithms.html#torch.use_deterministic_algorithms
  
  Args:
      spatial_dims: number of spatial dimensions of the input image.
      in_channels: number of the input channel.
      out_channels: number of the output classes.
      init_features: number of filters in the first convolution layer.
      growth_rate: how many filters to add each layer (k in paper).
      block_config: how many layers in each pooling block.
      bn_size: multiplicative factor for number of bottle neck layers.
          (i.e. bn_size * k features in the bottleneck layer)
      act: activation type and arguments. Defaults to relu.
      norm: feature normalization type and arguments. Defaults to batch norm.
      dropout_prob: dropout rate after each dense layer.
code: def __init__(
      self,
      spatial_dims: int,
      in_channels: int,
      out_channels: int,
      init_features: int = 64,
      growth_rate: int = 32,
      block_config: Sequence[int] = (6, 12, 24, 16),
      bn_size: int = 4,
      act: str | tuple = ("relu", {"inplace": True}),
      norm: str | tuple = "batch",
      dropout_prob: float = 0.0,
  ) -> None:
      super().__init__()
  
      conv_type: type[nn.Conv1d | nn.Conv2d | nn.Conv3d] = Conv[
          Conv.CONV, spatial_dims
      ]
      pool_type: type[
          nn.MaxPool1d | nn.MaxPool2d | nn.MaxPool3d
      ] = Pool[Pool.MAX, spatial_dims]
      avg_pool_type: type[
          nn.AdaptiveAvgPool1d
          | nn.AdaptiveAvgPool2d
          | nn.AdaptiveAvgPool3d
      ] = Pool[Pool.ADAPTIVEAVG, spatial_dims]
  
      self.features = nn.Sequential(
          OrderedDict(
              [
                  (
                      "conv0",
                      conv_type(
                          in_channels,
                          init_features,
                          kernel_size=7,
                          stride=2,
                          padding=3,
                          bias=False,
                      ),
                  ),
                  (
                      "norm0",
                      get_norm_layer(
                          name=norm,
                          spatial_dims=spatial_dims,
                          channels=init_features,
                      ),
                  ),
                  ("relu0", get_act_layer(name=act)),
                  (
                      "pool0",
                      pool_type(kernel_size=3, stride=2, padding=1),
                  ),
              ]
          )
      )
  
      in_channels = init_features
      for i, num_layers in enumerate(block_config):
          block = _DenseBlock(
              spatial_dims=spatial_dims,
              layers=num_layers,
              in_channels=in_channels,
              bn_size=bn_size,
              growth_rate=growth_rate,
              dropout_prob=dropout_prob,
              act=act,
              norm=norm,
          )
          self.features.add_module(f"denseblock{i + 1}", block)
          in_channels += num_layers * growth_rate
          if i == len(block_config) - 1:
              self.features.add_module(
                  "norm5",
                  get_norm_layer(
                      name=norm,
                      spatial_dims=spatial_dims,
                      channels=in_channels,
                  ),
              )
          else:
              _out_channels = in_channels // 2
              trans = _Transition(
                  spatial_dims,
                  in_channels=in_channels,
                  out_channels=_out_channels,
                  act=act,
                  norm=norm,
              )
              self.features.add_module(f"transition{i + 1}", trans)
              in_channels = _out_channels
  
      # pooling and classification
      self.class_layers = nn.Sequential(
          OrderedDict(
              [
                  ("relu", get_act_layer(name=act)),
                  ("pool", avg_pool_type(1)),
                  ("flatten", nn.Flatten(1)),
                  ("out", nn.Linear(in_channels, out_channels)),
              ]
          )
      )
  
      for m in self.modules():
          if isinstance(m, conv_type):
              nn.init.kaiming_normal_(torch.as_tensor(m.weight))
          elif isinstance(
              m, (nn.BatchNorm1d, nn.BatchNorm2d, nn.BatchNorm3d)
          ):
              nn.init.constant_(torch.as_tensor(m.weight), 1)
              nn.init.constant_(torch.as_tensor(m.bias), 0)
          elif isinstance(m, nn.Linear):
              nn.init.constant_(torch.as_tensor(m.bias), 0)
  
imports: from __future__ import annotations
  import re
  from collections import OrderedDict
  from collections.abc import Callable, Sequence
  import torch
  import torch.nn
  from torch.hub import load_state_dict_from_url
  from monai.networks.layers.factories import Conv, Dropout, Pool
  from monai.networks.layers.utils import get_act_layer, get_norm_layer
  from monai.utils.module import look_up_option
label_desc: Use image node_id 1 to create a new DenseNet object from inherited base classes: nn with example: obj = DenseNet(spatial_dims, in_channels, out_channels, init_features, growth_rate, block_config, bn_size, act, norm, dropout_prob)