code: def get_logits(self, image):
      if BITW == "t":
          fw, fa, fg = get_dorefa(32, 32, 32)
          fw = ternarize
      else:
          fw, fa, fg = get_dorefa(BITW, BITA, BITG)
  
      # monkey-patch tf.get_variable to apply fw
      def new_get_variable(v):
          name = v.op.name
          # don't binarize first and last layer
          if not name.endswith("W") or "conv0" in name or "fct" in name:
              return v
          else:
              logger.info("Quantizing weight {}".format(v.op.name))
              return fw(v)
  
      def nonlin(x):
          if BITA == 32:
              return tf.nn.relu(x)  # still use relu for 32bit cases
          return tf.clip_by_value(x, 0.0, 1.0)
  
      def activate(x):
          return fa(nonlin(x))
  
      with remap_variables(new_get_variable), argscope(
          [Conv2D, BatchNorm, MaxPooling], data_format="channels_first"
      ), argscope(BatchNorm, momentum=0.9, epsilon=1e-4), argscope(
          Conv2D, use_bias=False
      ):
          logits = (
              LinearWrap(image)
              .Conv2D(
                  "conv0",
                  96,
                  12,
                  strides=4,
                  padding="VALID",
                  use_bias=True,
              )
              .apply(activate)
              .Conv2D("conv1", 256, 5, padding="SAME", split=2)
              .apply(fg)
              .BatchNorm("bn1")
              .MaxPooling("pool1", 3, 2, padding="SAME")
              .apply(activate)
              .Conv2D("conv2", 384, 3)
              .apply(fg)
              .BatchNorm("bn2")
              .MaxPooling("pool2", 3, 2, padding="SAME")
              .apply(activate)
              .Conv2D("conv3", 384, 3, split=2)
              .apply(fg)
              .BatchNorm("bn3")
              .apply(activate)
              .Conv2D("conv4", 256, 3, split=2)
              .apply(fg)
              .BatchNorm("bn4")
              .MaxPooling("pool4", 3, 2, padding="VALID")
              .apply(activate)
              .FullyConnected("fc0", 4096)
              .apply(fg)
              .BatchNorm("bnfc0")
              .apply(activate)
              .FullyConnected("fc1", 4096, use_bias=False)
              .apply(fg)
              .BatchNorm("bnfc1")
              .apply(nonlin)
              .FullyConnected("fct", 1000, use_bias=True)()
          )
      add_param_summary((".*/W", ["histogram", "rms"]))
      tf.nn.softmax(logits, name="output")  # for prediction
      return logits
  
imports: import argparse
  import numpy
  import os
  import sys
  import cv2
  import tensorflow
  from tensorpack import *
  from tensorpack.dataflow import dataset
  from tensorpack.tfutils.sessinit import SmartInit
  from tensorpack.tfutils.summary import add_param_summary
  from tensorpack.tfutils.varreplace import remap_variables
  from tensorpack.utils.gpu import get_num_gpu
  from dorefa import get_dorefa, ternarize
  from imagenet_utils import ImageNetModel, eval_classification, fbresnet_augmentor, get_imagenet_dataflow
label_desc: Use image node_id 1 for calling the Model obj's underlying member method code with example usage: obj.get_logits(image) and returns: logits, tf, fa, v, fw, tf