code: def bit_to_int(x_bit, num_bits, base=2):
    
    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]))
docs: 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.