code: def bit_to_int(x_bit, num_bits, base=2):
      """Turn x_bit representing numbers bitwise (lower-endian) to int tensor.
  
      Args:
        x_bit: Tensor containing numbers in a particular base to be converted to
          int.
        num_bits: Number of bits in the representation.
        base: Base of the representation.
  
      Returns:
        Integer representation of this number.
      """
      x_l = tf.stop_gradient(
          tf.to_int32(tf.reshape(x_bit, [-1, num_bits]))
      )
      x_labels = [
          x_l[:, i] * tf.to_int32(base) ** tf.to_int32(i)
          for i in range(num_bits)
      ]
      res = sum(x_labels)
      return tf.to_int32(
          tf.reshape(res, common_layers.shape_list(x_bit)[:-1])
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from functools import partial
  from tensor2tensor.layers import common_hparams
  from tensor2tensor.layers import common_image_attention
  from tensor2tensor.layers import common_layers
  import tensorflow.compat.v1
  from tensorflow.compat.v1 import estimator
  import tensorflow_probability
  from tensorflow.python.training import moving_averages
label_desc: Use image node_id 5 for calling a global function with example usage: bit_to_int(x_bit, num_bits, base) and returns: tf