code: def build_encoder(
      arch="resnet50_dilated8", fc_dim=512, weights="", **kwargs
  ):
      pretrained = len(weights) == 0
      if arch == "resnet34":
          raise NotImplementedError
      if arch == "resnet34_dilated8":
          raise NotImplementedError
      if arch == "resnet34_dilated16":
          raise NotImplementedError
      if arch == "resnet50":
          orig_resnet = resnet.resnet50(**kwargs)
          net_encoder = Resnet(orig_resnet)
      elif arch == "resnet50_dilated8":
          orig_resnet = resnet.resnet50(**kwargs)
          net_encoder = ResnetDilated(orig_resnet, dilate_scale=8)
      elif arch == "resnet50_dilated16":
          orig_resnet = resnet.resnet50(**kwargs)
          net_encoder = ResnetDilated(orig_resnet, dilate_scale=16)
      elif arch == "resnet101":
          orig_resnet = resnet.resnet101(**kwargs)
          net_encoder = Resnet(orig_resnet)
      elif arch == "resnet101_dilated8":
          orig_resnet = resnet.resnet101(**kwargs)
          net_encoder = ResnetDilated(orig_resnet, dilate_scale=8)
      elif arch == "resnet101_dilated16":
          orig_resnet = resnet.resnet101(**kwargs)
          net_encoder = ResnetDilated(orig_resnet, dilate_scale=16)
      elif arch == "resnext101":
          orig_resnext = resnext.resnext101(**kwargs)
          net_encoder = Resnet(
              orig_resnext
          )  # we can still use class Resnet
      else:
          raise Exception("Architecture undefined!")
  
      # net_encoder.apply(self.weights_init)
      if len(weights) > 0:
          print("Loading weights for net_encoder")
          net_encoder.load_state_dict(
              torch.load(
                  weights, map_location=lambda storage, loc: storage
              ),
              strict=False,
          )
      return net_encoder
  
imports: import torch
  import torch.nn
  import torch.nn.functional
  from .None import seg_resnet
  from .None import seg_resnext
label_desc: Use image node_id 2 for calling the ModelBuilder obj's underlying member method code with example usage: obj.build_encoder(arch, fc_dim, weights) and returns: net_encoder