code: def build_graph(self, image, edgemap):
      image = image - tf.constant([104, 116, 122], dtype="float32")
      image = tf.transpose(image, [0, 3, 1, 2])
      edgemap = tf.expand_dims(edgemap, 3, name="edgemap4d")
  
      def branch(name, l, up):
          with tf.variable_scope(name):
              l = Conv2D(
                  "convfc",
                  l,
                  1,
                  kernel_size=1,
                  activation=tf.identity,
                  use_bias=True,
                  kernel_initializer=tf.constant_initializer(),
              )
              while up != 1:
                  l = CaffeBilinearUpSample(
                      "upsample{}".format(up), l, 2
                  )
                  up = up // 2
              return l
  
      with argscope(
          Conv2D, kernel_size=3, activation=tf.nn.relu
      ), argscope([Conv2D, MaxPooling], data_format="NCHW"):
          l = Conv2D("conv1_1", image, 64)
          l = Conv2D("conv1_2", l, 64)
          b1 = branch("branch1", l, 1)
          l = MaxPooling("pool1", l, 2)
  
          l = Conv2D("conv2_1", l, 128)
          l = Conv2D("conv2_2", l, 128)
          b2 = branch("branch2", l, 2)
          l = MaxPooling("pool2", l, 2)
  
          l = Conv2D("conv3_1", l, 256)
          l = Conv2D("conv3_2", l, 256)
          l = Conv2D("conv3_3", l, 256)
          b3 = branch("branch3", l, 4)
          l = MaxPooling("pool3", l, 2)
  
          l = Conv2D("conv4_1", l, 512)
          l = Conv2D("conv4_2", l, 512)
          l = Conv2D("conv4_3", l, 512)
          b4 = branch("branch4", l, 8)
          l = MaxPooling("pool4", l, 2)
  
          l = Conv2D("conv5_1", l, 512)
          l = Conv2D("conv5_2", l, 512)
          l = Conv2D("conv5_3", l, 512)
          b5 = branch("branch5", l, 16)
  
          final_map = Conv2D(
              "convfcweight",
              tf.concat([b1, b2, b3, b4, b5], 1),
              1,
              kernel_size=1,
              kernel_initializer=tf.constant_initializer(0.2),
              use_bias=False,
              activation=tf.identity,
          )
      costs = []
      for idx, b in enumerate([b1, b2, b3, b4, b5, final_map]):
          b = tf.transpose(b, [0, 2, 3, 1])
          output = tf.nn.sigmoid(b, name="output{}".format(idx + 1))
          xentropy = class_balanced_sigmoid_cross_entropy(
              b, edgemap, name="xentropy{}".format(idx + 1)
          )
          costs.append(xentropy)
  
      # some magic threshold
      pred = tf.cast(
          tf.greater(output, 0.5), tf.int32, name="prediction"
      )
      wrong = tf.cast(tf.not_equal(pred, edgemap), tf.float32)
      wrong = tf.reduce_mean(wrong, name="train_error")
  
      wd_w = tf.train.exponential_decay(
          2e-4, get_global_step_var(), 80000, 0.7, True
      )
      wd_cost = tf.multiply(
          wd_w, regularize_cost(".*/W", tf.nn.l2_loss), name="wd_cost"
      )
      costs.append(wd_cost)
  
      add_param_summary((".*/W", ["histogram"]))  # monitor W
      total_cost = tf.add_n(costs, name="cost")
      add_moving_summary(wrong, total_cost, *costs)
      return total_cost
  
imports: import argparse
  import numpy
  import os
  import cv2
  import tensorflow
  from tensorpack import *
  from tensorpack.dataflow import dataset
  from tensorpack.tfutils import gradproc, optimizer
  from tensorpack.tfutils.summary import add_moving_summary, add_param_summary
  from tensorpack.utils.gpu import get_num_gpu
  from tensorpack.utils import logger
label_desc: Use image node_id 2 for calling the Model obj's underlying member method code with example usage: obj.build_graph(image, edgemap) and returns: total_cost, l