code: def __init__(self, cfg: dict, out_ch: int = 1):
      super().__init__()
      assert "encode" in cfg
      assert "decode" in cfg
      self.encode_num = len(cfg["encode"])
  
      encode_list = []
      side_list = []
      for c in cfg["encode"]:
          # c: [height, in_ch, mid_ch, out_ch, RSU4F, side]
          assert len(c) == 6
          encode_list.append(
              RSU(*c[:4]) if c[4] is False else RSU4F(*c[1:4])
          )
  
          if c[5] is True:
              side_list.append(
                  nn.Conv2d(c[3], out_ch, kernel_size=3, padding=1)
              )
      self.encode_modules = nn.ModuleList(encode_list)
  
      decode_list = []
      for c in cfg["decode"]:
          # c: [height, in_ch, mid_ch, out_ch, RSU4F, side]
          assert len(c) == 6
          decode_list.append(
              RSU(*c[:4]) if c[4] is False else RSU4F(*c[1:4])
          )
  
          if c[5] is True:
              side_list.append(
                  nn.Conv2d(c[3], out_ch, kernel_size=3, padding=1)
              )
      self.decode_modules = nn.ModuleList(decode_list)
      self.side_modules = nn.ModuleList(side_list)
      self.out_conv = nn.Conv2d(
          self.encode_num * out_ch, out_ch, kernel_size=1
      )
  
imports: from typing import Union, List
  import torch
  import torch.nn
  import torch.nn.functional
label_desc: Use image node_id 1 to create a new U2Net object from inherited base classes: nn with example: obj = U2Net(cfg, out_ch)