code: def layer_op(self, image, conditioning, is_training):
      conditioning = tf.image.resize_images(conditioning, [160, 120])
  
      batch_size = image.shape.as_list()[0]
  
      w_init = tf.random_normal_initializer(0, 0.02)
      b_init = tf.constant_initializer(0.001)
  
      def leaky_relu(x, alpha=0.2):
          with tf.name_scope("leaky_relu"):
              return 0.5 * (1 + alpha) * x + 0.5 * (1 - alpha) * abs(x)
  
      ch = [32, 64, 128, 256, 512, 1024]
  
      def down(ch, x):
          with tf.name_scope("downsample"):
              c = ConvolutionalLayer(
                  ch,
                  3,
                  stride=2,
                  feature_normalization=None,
                  w_initializer=w_init,
              )(x, is_training=is_training)
              c = tf.contrib.layers.batch_norm(c)
              c = leaky_relu(c)
              return c
  
      def convr(ch, x):
          c = ConvolutionalLayer(
              ch, 3, feature_normalization=None, w_initializer=w_init
          )(x, is_training=is_training)
          return leaky_relu(tf.contrib.layers.batch_norm(c))
  
      def conv(ch, x, s):
          c = ConvolutionalLayer(
              ch, 3, feature_normalization=None, w_initializer=w_init
          )(x, is_training=is_training)
          return leaky_relu(tf.contrib.layers.batch_norm(c) + s)
  
      def down_block(ch, x):
          with tf.name_scope("down_resnet"):
              s = down(ch, x)
              r = convr(ch, s)
              return conv(ch, r, s)
  
      if not conditioning is None:
          image = tf.concat([image, conditioning], axis=-1)
      with tf.name_scope("feature"):
          d_h1s = ConvolutionalLayer(
              ch[0],
              5,
              with_bias=True,
              feature_normalization=None,
              w_initializer=w_init,
              b_initializer=b_init,
          )(image, is_training=is_training)
  
          d_h1s = leaky_relu(d_h1s)
          d_h1r = convr(ch[0], d_h1s)
          d_h1 = conv(ch[0], d_h1r, d_h1s)
      d_h2 = down_block(ch[1], d_h1)
      d_h3 = down_block(ch[2], d_h2)
      d_h4 = down_block(ch[3], d_h3)
      d_h5 = down_block(ch[4], d_h4)
      d_h6 = down_block(ch[5], d_h5)
      with tf.name_scope("fc"):
          d_hf = tf.reshape(d_h6, [batch_size, -1])
          d_nf_o = np.prod(d_hf.shape.as_list()[1:])
          D_Wo = tf.get_variable(
              "D_Wo", shape=[d_nf_o, 1], initializer=w_init
          )
          D_bo = tf.get_variable("D_bo", shape=[1], initializer=b_init)
  
          d_logit = tf.matmul(d_hf, D_Wo) + D_bo
      if self.load_from_checkpoint:
          checkpoint_name = (
              "/home/egibson/deeplearning/TensorFlow/NiftyNet/NiftyNet/"
              + "contrib/ultrasound_simulator_gan/ultrasound_simulator_gan"
          )
          restores = [
              ["D_b1s", "discriminator/conv/conv_/b"],
              ["D_W1s", "discriminator/conv/conv_/w"],
              ["D_W1r1", "discriminator/conv_1/conv_/w"],
              ["D_W1r2", "discriminator/conv_2/conv_/w"],
              ["D_W2s", "discriminator/conv_3/conv_/w"],
              ["D_W2r1", "discriminator/conv_4/conv_/w"],
              ["D_W2r2", "discriminator/conv_5/conv_/w"],
              ["D_W3s", "discriminator/conv_6/conv_/w"],
              ["D_W3r1", "discriminator/conv_7/conv_/w"],
              ["D_W3r2", "discriminator/conv_8/conv_/w"],
              ["D_W4s", "discriminator/conv_9/conv_/w"],
              ["D_W4r1", "discriminator/conv_10/conv_/w"],
              ["D_W4r2", "discriminator/conv_11/conv_/w"],
              ["D_W5s", "discriminator/conv_12/conv_/w"],
              ["D_W5r1", "discriminator/conv_13/conv_/w"],
              ["D_W5r2", "discriminator/conv_14/conv_/w"],
              ["D_W6s", "discriminator/conv_15/conv_/w"],
              ["D_W6r1", "discriminator/conv_16/conv_/w"],
              ["D_W6r2", "discriminator/conv_17/conv_/w"],
              ["D_Wo", "discriminator/D_Wo"],
              ["D_bo", "discriminator/D_bo"],
          ]
          [
              tf.add_to_collection(
                  "NiftyNetObjectsToRestore",
                  (r[1], checkpoint_name, r[0]),
              )
              for r in restores
          ]
      return d_logit
  
file_path: NiftyNet/niftynet/contrib/ultrasound_simulator_gan/ultrasound_simulator_gan.py
imports: from __future__ import absolute_import, print_function
  import tensorflow
  import numpy
  from niftynet.layer.convolution import ConvolutionalLayer
  from niftynet.layer.deconvolution import DeconvolutionalLayer
  from niftynet.layer.gan_blocks import GANImageBlock, BaseGenerator, BaseDiscriminator
label_desc: Use image node_id 2 for calling the ImageDiscriminator obj's underlying member method code with example usage: obj.layer_op(image, conditioning, is_training) and returns: d_logit, leaky_relu, leaky_relu, unknown, c, conv