code: def build_graph(self, A, B):
      with tf.name_scope("preprocess"):
          A = tf.transpose(A / 128.0 - 1.0, [0, 3, 1, 2])
          B = tf.transpose(B / 128.0 - 1.0, [0, 3, 1, 2])
  
      def viz3(name, a, b, c):
          with tf.name_scope(name):
              im = tf.concat([a, b, c], axis=3)
              im = tf.transpose(im, [0, 2, 3, 1])
              im = (im + 1.0) * 128
              im = tf.clip_by_value(im, 0, 255)
              im = tf.cast(im, tf.uint8, name="viz")
          tf.summary.image(name, im, max_outputs=50)
  
      # use the initializers from torch
      with argscope(
          [Conv2D, Conv2DTranspose],
          use_bias=False,
          kernel_initializer=tf.random_normal_initializer(stddev=0.02),
      ), argscope(
          [Conv2D, Conv2DTranspose, InstanceNorm],
          data_format="channels_first",
      ):
          with tf.variable_scope("gen"):
              with tf.variable_scope("B"):
                  AB = self.generator(A)
              with tf.variable_scope("A"):
                  BA = self.generator(B)
                  ABA = self.generator(AB)
              with tf.variable_scope("B"):
                  BAB = self.generator(BA)
  
          viz3("A_recon", A, AB, ABA)
          viz3("B_recon", B, BA, BAB)
  
          with tf.variable_scope("discrim"):
              with tf.variable_scope("A"):
                  A_dis_real = self.discriminator(A)
                  A_dis_fake = self.discriminator(BA)
  
              with tf.variable_scope("B"):
                  B_dis_real = self.discriminator(B)
                  B_dis_fake = self.discriminator(AB)
  
      def LSGAN_losses(real, fake):
          d_real = tf.reduce_mean(
              tf.squared_difference(real, 1), name="d_real"
          )
          d_fake = tf.reduce_mean(tf.square(fake), name="d_fake")
          d_loss = tf.multiply(d_real + d_fake, 0.5, name="d_loss")
  
          g_loss = tf.reduce_mean(
              tf.squared_difference(fake, 1), name="g_loss"
          )
          add_moving_summary(g_loss, d_loss)
          return g_loss, d_loss
  
      with tf.name_scope("losses"):
          with tf.name_scope("LossA"):
              # reconstruction loss
              recon_loss_A = tf.reduce_mean(
                  tf.abs(A - ABA), name="recon_loss"
              )
              # gan loss
              G_loss_A, D_loss_A = LSGAN_losses(A_dis_real, A_dis_fake)
  
          with tf.name_scope("LossB"):
              recon_loss_B = tf.reduce_mean(
                  tf.abs(B - BAB), name="recon_loss"
              )
              G_loss_B, D_loss_B = LSGAN_losses(B_dis_real, B_dis_fake)
  
          LAMBDA = 10.0
          self.g_loss = tf.add(
              (G_loss_A + G_loss_B),
              (recon_loss_A + recon_loss_B) * LAMBDA,
              name="G_loss_total",
          )
          self.d_loss = tf.add(D_loss_A, D_loss_B, name="D_loss_total")
      self.collect_variables("gen", "discrim")
  
      add_moving_summary(
          recon_loss_A, recon_loss_B, self.g_loss, self.d_loss
      )
  
imports: import argparse
  import glob
  import os
  import tensorflow
  from six.moves import range
  from tensorpack import *
  from tensorpack.tfutils.scope_utils import auto_reuse_variable_scope
  from tensorpack.tfutils.summary import add_moving_summary
  from GAN import GANModelDesc, GANTrainer
label_desc: Use image node_id 5 for calling the Model obj's underlying member method code with example usage: obj.build_graph(A, B) and returns: g_loss,  d_loss