code: def quantize_weight(x, bitW, force_quantization=False):
      G = tf.compat.v1.get_default_graph()
      if bitW == 32 and not force_quantization:
          return x
      if bitW == 1:  # BWN
          with G.gradient_override_map({"Sign": "Identity"}):
              E = tf.stop_gradient(
                  tf.reduce_mean(input_tensor=tf.abs(x))
              )
              return tf.sign(x / E) * E
      x = tf.clip_by_value(
          x * 0.5 + 0.5, 0.0, 1.0
      )  # it seems as though most weights are within -1 to 1 region anyways
      return 2 * _quantize_dorefa(x, bitW) - 1
  
imports: import numpy
  import tensorflow
  from tensorflow.python.ops.rnn_cell import LSTMStateTuple
  import tensorlayer
  from tensorlayer import logging
  from tensorlayer.decorators import deprecated, deprecated_alias
label_desc: Use image node_id 15 for calling a global function with example usage: quantize_weight(x, bitW, force_quantization) and returns: unknown, x, unknown