code: def __init__(
      self,
      depth,
      ch,
      norm_layer,
      batchnorm_from,
      max_channels,
      backbone_from,
      backbone_channels=None,
      backbone_mode="",
  ):
      super(ConvEncoder, self).__init__()
      self.depth = depth
      self.backbone_from = backbone_from
      backbone_channels = (
          [] if backbone_channels is None else backbone_channels[::-1]
      )
  
      in_channels = 4
      out_channels = ch
  
      self.block0 = ConvBlock(
          in_channels,
          out_channels,
          norm_layer=norm_layer if batchnorm_from == 0 else None,
      )
      self.block1 = ConvBlock(
          out_channels,
          out_channels,
          norm_layer=norm_layer if 0 <= batchnorm_from <= 1 else None,
      )
      self.blocks_channels = [out_channels, out_channels]
  
      self.blocks_connected = nn.ModuleDict()
      self.connectors = nn.ModuleDict()
      for block_i in range(2, depth):
          if block_i % 2:
              in_channels = out_channels
          else:
              in_channels, out_channels = out_channels, min(
                  2 * out_channels, max_channels
              )
  
          if 0 <= backbone_from <= block_i and len(backbone_channels):
              stage_channels = backbone_channels.pop()
              connector = FeaturesConnector(
                  backbone_mode,
                  in_channels,
                  stage_channels,
                  in_channels,
              )
              self.connectors[f"connector{block_i}"] = connector
              in_channels = connector.output_channels
  
          self.blocks_connected[f"block{block_i}"] = ConvBlock(
              in_channels,
              out_channels,
              norm_layer=norm_layer
              if 0 <= batchnorm_from <= block_i
              else None,
              padding=int(block_i < depth - 1),
          )
          self.blocks_channels += [out_channels]
  
file_path: carefree-learn/cflearn/api/cv/third_party/iharm/model/modeling/conv_autoencoder.py
imports: import torch
  import torch.nn
  from .basic_blocks import ConvBlock
  from ..ops import FeaturesConnector
  from ..ops import MaskedChannelAttention
label_desc: Use image node_id 1 to create a new ConvEncoder object from inherited base classes: nn with example: obj = ConvEncoder(depth, ch, norm_layer, batchnorm_from, max_channels, backbone_from, backbone_channels, backbone_mode)