code: def __init__(
      self,
      in_dim: int,
      out_dim: int,
      *,
      bias: Optional[bool] = None,
      pruner_config: Optional[dict] = None,
      dropout: float = 0.0,
      batch_norm: bool = True,
      activation: Optional[str] = "ReLU",
      activation_config: Optional[Dict[str, Any]] = None,
      init_method: str = "xavier_normal",
  ):
      super().__init__()
      # input mapping
      if in_dim == out_dim:
          self.to_latent = nn.Identity()
      else:
          self.to_latent = Linear(
              in_dim,
              out_dim,
              bias=True if bias is None else bias,
              pruner_config=pruner_config,
              init_method=init_method,
          )
      # residual unit
      self.residual_unit = nn.Sequential(
          BN(out_dim) if batch_norm else nn.Identity(),
          Activation.make(activation, activation_config),
          nn.Identity()
          if not 0.0 < dropout < 1.0
          else nn.Dropout(dropout),
          Linear(
              out_dim,
              out_dim,
              bias=True if bias is None else bias,
              pruner_config=pruner_config,
              init_method=init_method,
          ),
          nn.Identity()
          if not 0.0 < dropout < 1.0
          else nn.Dropout(dropout),
      )
  
imports: import torch.nn
  from torch import Tensor
  from typing import Any
  from typing import Dict
  from typing import Type
  from typing import Optional
  from torch.nn import Module
  from cftool.misc import WithRegister
  from .norms import BN
  from .customs import Linear
  from .activations import Activation
label_desc: Use image node_id 1 to create a new ResBlock object from inherited base classes: MappingBase with example: obj = ResBlock(in_dim, out_dim)