code: def testPCQATTrainingE2E(self):
      # Baseline model training
      model = baseline_model()
  
      # Prune the model to have 50% sparsity
      pruned_model, pruned_stripped = _prune_model(model)
      sparsity_pruning = _check_sparsity_kernel(pruned_model)
  
      # Cluster the model with 8 clusters
      preserve_sparsity = True
      clustered_model, clustered_model_stripped = _cluster_model(
          pruned_stripped, preserve_sparsity
      )
      _, (x_test, y_test) = _get_dataset()
      pc_result = clustered_model.evaluate(x_test, y_test)
      self.assertGreater(pc_result[1], 0.8)
  
      # Case 1: apply PCQAT to the pruned_clustered_model with preserve_sparsity
      # flag on
      (
          pcqat_model,
          pcqat_model_stripped,
      ) = prune_cluster_preserve_quantize_model(
          clustered_model_stripped, True
      )
  
      # Evaluate the fp32 result of PCQAT
      pcqat_result = pcqat_model.evaluate(x_test, y_test)
      self.assertGreater(pcqat_result[1], 0.8)
  
      # Check the unique weights of clustered_model and pcqat_model
      num_of_unique_weights_clst = _get_num_unique_weights_kernel(
          clustered_model_stripped
      )
      num_of_unique_weights_pcqat = _get_num_unique_weights_kernel(
          pcqat_model_stripped
      )
      self.assertAllEqual(
          num_of_unique_weights_clst, num_of_unique_weights_pcqat
      )
      # Check number of unique weights after clustering and pcqat should be
      # less or equal to 8
      # Re-enable this check after PR #702 is merged
      # self.assertAllLessEqual(num_of_unique_weights_clst, 8)
  
      # Compare sparsity per layer for pruned_model and pcqat_model
      sparsity_pcqat = _check_sparsity_kernel(pcqat_model)
      # The sparsity in pcqat should be greater or euqal to the original
      # uniform sparsity per layer. In this example, 0.5
      self.assertAllGreaterEqual(
          np.array(sparsity_pcqat), sparsity_pruning[0]
      )
  
      # Verify the tflite conversion and accuracy
      tflite_accuracy = _check_tflite_conversion(
          pcqat_model_stripped, False
      )
      self.assertGreater(tflite_accuracy, 0.8)
  
      # Check the accuracy of PCQAT is not worse than the one of PC
      self.assertGreaterEqual(pcqat_result[1], pc_result[1])
  
      # Case 2: when the preserve_sparsity flag is False, the final sparsity
      # of pcqat should be destroyed
      (
          pcqat_model,
          pcqat_model_stripped,
      ) = prune_cluster_preserve_quantize_model(
          clustered_model_stripped, False
      )
      # Check unique weights
      num_of_unique_weights_pcqat = _get_num_unique_weights_kernel(
          pcqat_model_stripped
      )
      self.assertAllEqual(
          num_of_unique_weights_clst, num_of_unique_weights_pcqat
      )
  
      # Compare sparsity per layer for pruned_model and pcqat_model
      sparsity_pcqat = _check_sparsity_kernel(pcqat_model)
      # The sparsity in pcqat should be less than the original
      # uniform sparsity per layer. In this example, 0.5
      self.assertAllLess(np.array(sparsity_pcqat), sparsity_pruning[0])
  
imports: import numpy
  import tensorflow
  from tensorflow_model_optimization.python.core.clustering.keras import cluster
  from tensorflow_model_optimization.python.core.clustering.keras import cluster_config
  from tensorflow_model_optimization.python.core.clustering.keras.experimental import cluster
  from tensorflow_model_optimization.python.core.quantization.keras import quantize
  from tensorflow_model_optimization.python.core.quantization.keras.collab_opts.cluster_preserve import cluster_utils
  from tensorflow_model_optimization.python.core.quantization.keras.collab_opts.cluster_preserve import default_8bit_cluster_preserve_quantize_scheme
  from tensorflow_model_optimization.python.core.sparsity.keras import prune
  from tensorflow_model_optimization.python.core.sparsity.keras import pruning_callbacks
  from tensorflow_model_optimization.python.core.sparsity.keras import pruning_schedule
label_desc: Use image node_id 1 for calling the FunctionalTest obj's underlying member method code with example usage: obj.testPCQATTrainingE2E() without return types