class_docstr: Test for PerChannelPRNGUniformQuantizationEncodingStage.
class_docstr_tok: ["Test","for","PerChannelPRNGUniformQuantizationEncodingStage","."]
code: def test_quantization_bits_stochastic_rounding(self, bits):
      stage = (
          quantization.PerChannelPRNGUniformQuantizationEncodingStage(
              bits=bits
          )
      )
      test_data = self.run_one_to_many_encode_decode(
          stage, self.default_input
      )
      self._assert_is_integer_float(
          test_data.encoded_x[
              quantization.PerChannelPRNGUniformQuantizationEncodingStage.ENCODED_VALUES_KEY
          ]
      )
      # For stochastic rounding, the potential error incurred by quantization
      # is bounded by the range of the input values divided by the number of
      # quantization buckets.
      self.assertAllClose(
          test_data.x,
          test_data.decoded_x,
          rtol=0.0,
          atol=2 / (2**bits - 1),
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import itertools
  from absl.testing import parameterized
  import numpy
  import tensorflow
  from tensorflow_model_optimization.python.core.internal.tensor_encoding.stages.research import quantization
  from tensorflow_model_optimization.python.core.internal.tensor_encoding.testing import test_utils
label_desc: Use image node_id 6 for calling the PerChannelPRNGUniformQuantizationEncodingStageTest obj's underlying member method code with example usage: obj.test_quantization_bits_stochastic_rounding(bits) without return types