docstr: Residual block.
  
  References:
      He, Kaiming, et al. "Deep residual learning for image
      recognition." Proceedings of the IEEE conference on computer
      vision and pattern recognition. 2016.
  
  Args:
      layers: number of layers in the block.
      num_features: number of internal features used.
      in_channels: number of the input channel.
      out_channels: number of the output channel.
      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.
      freeze_dense_layer: whether to freeze all dense layers within the block.
      freeze_block: whether to freeze the whole block.
docstr_tok: ["Residual","block",".","References",":","He",",","Kaiming",",","et","al",".","``","Deep","residual","learning","for","image","recognition",".","''","Proceedings","of","the","IEEE","conference","on","computer","vision","and","pattern","recognition",".","2016",".","Args",":","layers",":","number","of","layers","in","the","block",".","num_features",":","number","of","internal","features","used",".","in_channels",":","number","of","the","input","channel",".","out_channels",":","number","of","the","output","channel",".","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",".","freeze_dense_layer",":","whether","to","freeze","all","dense","layers","within","the","block",".","freeze_block",":","whether","to","freeze","the","whole","block","."]
code: def __init__(
      self,
      layers: int,
      num_features: int,
      in_channels: int,
      out_channels: int,
      dropout_prob: float = 0.0,
      act: str | tuple = ("relu", {"inplace": True}),
      norm: str | tuple = "batch",
      freeze_dense_layer: bool = False,
      freeze_block: bool = False,
  ) -> None:
      """Residual block.
  
      References:
          He, Kaiming, et al. "Deep residual learning for image
          recognition." Proceedings of the IEEE conference on computer
          vision and pattern recognition. 2016.
  
      Args:
          layers: number of layers in the block.
          num_features: number of internal features used.
          in_channels: number of the input channel.
          out_channels: number of the output channel.
          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.
          freeze_dense_layer: whether to freeze all dense layers within the block.
          freeze_block: whether to freeze the whole block.
  
      """
      super().__init__()
  
      self.layers = nn.Sequential()
      conv_type: Callable = Conv[Conv.CONV, 2]
  
      if in_channels == 64:
          self.shortcut = conv_type(
              in_channels, out_channels, kernel_size=1, bias=False
          )
      else:
          self.shortcut = conv_type(
              in_channels,
              out_channels,
              kernel_size=1,
              stride=2,
              padding=1,
              bias=False,
          )
  
      layer = _DenseLayer(
          num_features,
          in_channels,
          out_channels,
          dropout_prob,
          act=act,
          norm=norm,
          drop_first_norm_relu=True,
      )
      self.layers.add_module("denselayer_0", layer)
  
      for i in range(1, layers):
          layer = _DenseLayer(
              num_features,
              out_channels,
              out_channels,
              dropout_prob,
              act=act,
              norm=norm,
          )
          self.layers.add_module(f"denselayer_{i}", layer)
  
      self.bna_block = _Transition(out_channels, act=act, norm=norm)
  
      if freeze_dense_layer:
          self.layers.requires_grad_(False)
      if freeze_block:
          self.requires_grad_(False)
  
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 _ResidualBlock object from inherited base classes: nn with example: obj = _ResidualBlock(layers, num_features, in_channels, out_channels, dropout_prob, act, norm, freeze_dense_layer, freeze_block)