code: def test_is_lossless(self, bits, shape):
      # Tests that the encoding is lossless, for a variety of inputs.
      def x_fn():
          return tf.cast(
              tf.random.uniform(
                  shape, minval=0, maxval=2**bits - 1, dtype=tf.int32
              ),
              tf.float32,
          )
  
      stage = stages_impl.BitpackingEncodingStage(bits)
      test_data = self.run_one_to_many_encode_decode(stage, x_fn)
      self.assertAllClose(test_data.x, test_data.decoded_x)
      self.assertEqual(test_data.x.dtype, test_data.decoded_x.dtype)
  
imports: import itertools
  from absl.testing import parameterized
  import numpy
  import tensorflow
  from tensorflow_model_optimization.python.core.internal.tensor_encoding.stages import stages_impl
  from tensorflow_model_optimization.python.core.internal.tensor_encoding.testing import test_utils
label_desc: Use image node_id 5 for calling the BitpackingEncodingStageTest obj's underlying member method code with example usage: obj.test_is_lossless(bits, shape) and returns: tf