class_docstr: Test for PerChannelPRNGUniformQuantizationEncodingStage.
class_docstr_tok: ["Test","for","PerChannelPRNGUniformQuantizationEncodingStage","."]
code: def test_quantization_empirically_unbiased(self):
      # Tests that the quantization "seems" to be unbiased.
      # Executing the encoding and decoding many times, the average error should
      # be a lot larger than the error of average decoded value.
      x = tf.constant(np.random.rand((50)).astype(np.float32))
      stage = (
          quantization.PerChannelPRNGUniformQuantizationEncodingStage(
              bits=2
          )
      )
      encode_params, decode_params = stage.get_params()
      encoded_x, decoded_x = self.encode_decode_x(
          stage, x, encode_params, decode_params
      )
      test_data = test_utils.TestData(x, encoded_x, decoded_x)
      test_data_list = [
          self.evaluate_test_data(test_data) for _ in range(200)
      ]
  
      norm_errors = []
      errors = []
      for data in test_data_list:
          norm_errors.append(np.linalg.norm(data.x - data.decoded_x))
          errors.append(data.x - data.decoded_x)
      mean_of_errors = np.mean(norm_errors)
      error_of_mean = np.linalg.norm(np.mean(errors, axis=0))
      self.assertGreaterEqual(mean_of_errors, error_of_mean * 10)
  
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 7 for calling the PerChannelPRNGUniformQuantizationEncodingStageTest obj's underlying member method code with example usage: obj.test_quantization_empirically_unbiased() without return types