code: def __init__(self, config):
      super(Network, self).__init__()
  
      input_shape = config["input_shape"]
      n_classes = config["n_classes"]
  
      base_channels = config["base_channels"]
      self._remove_first_relu = config["remove_first_relu"]
      self._add_last_bn = config["add_last_bn"]
      block_type = config["block_type"]
      depth = config["depth"]
      preact_stage = config["preact_stage"]
  
      if block_type not in ["basic", "bottleneck"]:
          raise AssertionError
      if block_type == "basic":
          block = BasicBlock
          n_blocks_per_stage = (depth - 2) // 6
          if n_blocks_per_stage * 6 + 2 != depth:
              raise AssertionError
      else:
          block = BottleneckBlock
          n_blocks_per_stage = (depth - 2) // 9
          if n_blocks_per_stage * 9 + 2 != depth:
              raise AssertionError
  
      n_channels = [
          base_channels,
          base_channels * 2 * block.expansion,
          base_channels * 4 * block.expansion,
      ]
  
      self.conv = nn.Conv2d(
          input_shape[1],
          n_channels[0],
          kernel_size=(3, 3),
          stride=1,
          padding=1,
          bias=False,
      )
  
      self.stage1 = self._make_stage(
          n_channels[0],
          n_channels[0],
          n_blocks_per_stage,
          block,
          stride=1,
          preact=preact_stage[0],
      )
      self.stage2 = self._make_stage(
          n_channels[0],
          n_channels[1],
          n_blocks_per_stage,
          block,
          stride=2,
          preact=preact_stage[1],
      )
      self.stage3 = self._make_stage(
          n_channels[1],
          n_channels[2],
          n_blocks_per_stage,
          block,
          stride=2,
          preact=preact_stage[2],
      )
      self.bn = nn.BatchNorm2d(n_channels[2])
  
      # compute conv feature size
      with torch.no_grad():
          self.feature_size = (
              self._forward_conv(torch.zeros(*input_shape))
              .view(-1)
              .shape[0]
          )
  
      self.fc = nn.Linear(self.feature_size, n_classes)
  
      # initialize weights
      self.apply(initialize_weights)
  
imports: import torch
  import torch.nn
  import torch.nn.functional
  from collections import OrderedDict
label_desc: Use image node_id 1 to create a new Network object from inherited base classes: nn with example: obj = Network(config)