code: def testCensusExampleAccuracy(self, read_raw_data_for_training):
      if not self._should_saved_model_load_work():
          self.skipTest(
              "The generated SavedModel cannot be read with TF<2.2"
          )
      raw_data_dir = self._get_data_dir()
      working_dir = self._get_working_dir()
  
      train_data_file = os.path.join(raw_data_dir, "adult.data")
      test_data_file = os.path.join(raw_data_dir, "adult.test")
  
      census_example_common.transform_data(
          train_data_file, test_data_file, working_dir
      )
  
      if read_raw_data_for_training:
          raw_train_and_eval_patterns = (
              train_data_file,
              test_data_file,
          )
          transformed_train_and_eval_patterns = None
      else:
          train_pattern = os.path.join(
              working_dir,
              census_example_common.TRANSFORMED_TRAIN_DATA_FILEBASE
              + "*",
          )
          eval_pattern = os.path.join(
              working_dir,
              census_example_common.TRANSFORMED_TEST_DATA_FILEBASE
              + "*",
          )
          raw_train_and_eval_patterns = None
          transformed_train_and_eval_patterns = (
              train_pattern,
              eval_pattern,
          )
      output_dir = os.path.join(
          working_dir, census_example_common.EXPORTED_MODEL_DIR
      )
      results = census_example_v2.train_and_evaluate(
          raw_train_and_eval_patterns,
          transformed_train_and_eval_patterns,
          output_dir,
          working_dir,
          num_train_instances=1000,
          num_test_instances=1000,
      )
      self.assertGreaterEqual(results[1], 0.7)
  
      # Removing the tf.Transform output directory in order to show that the
      # exported model is hermetic.
      shutil.rmtree(os.path.join(working_dir, "transform_fn"))
  
      model_path = os.path.join(
          working_dir, census_example_common.EXPORTED_MODEL_DIR
      )
  
      actual_model_path = os.path.join(model_path, "1")
      tf_keras.backend.clear_session()
      model = tf_keras.models.load_model(actual_model_path)
      model.summary()
  
      example = text_format.Parse(
          _PREDICT_TF_EXAMPLE_TEXT_PB, tf.train.Example()
      )
      prediction = model.signatures["serving_default"](
          tf.constant([example.SerializeToString()], tf.string)
      )
      self.assertAllEqual([["0", "1"]], prediction["classes"])
      self.assertAllClose([[0, 1]], prediction["scores"], atol=0.01)
  
      # This is required in order to support the classify API for this Keras
      # model.
      updater = tf.compat.v1.saved_model.signature_def_utils.MethodNameUpdater(
          actual_model_path
      )
      updater.replace_method_name(
          signature_key="serving_default",
          method_name="tensorflow/serving/classify",
          tags=["serve"],
      )
      updater.save()
  
      if local_model_server.local_model_server_supported():
          with local_model_server.start_server(
              _MODEL_NAME, model_path
          ) as address:
              ascii_classification_request = (
                  _CLASSIFICATION_REQUEST_TEXT_PB
              )
              results = local_model_server.make_classification_request(
                  address, ascii_classification_request
              )
              self.assertEqual(len(results), 1)
              self.assertEqual(len(results[0].classes), 2)
              self.assertEqual(results[0].classes[0].label, "0")
              self.assertLess(results[0].classes[0].score, 0.01)
              self.assertEqual(results[0].classes[1].label, "1")
              self.assertGreater(results[0].classes[1].score, 0.99)
  
file_path: transform/examples/census_example_v2_test.py
imports: import os
  import shutil
  from packaging import version
  import tensorflow.compat.v2
  import census_example_common
  import census_example_v2
  from tensorflow_transform import test_case
  import local_model_server
  from tensorflow_transform.keras_lib import tf_keras
  from google.protobuf import text_format
  from tensorflow.python import tf2
label_desc: Use image node_id 5 for calling the CensusExampleV2Test obj's underlying member method code with example usage: obj.testCensusExampleAccuracy(read_raw_data_for_training) without return types