code: def test_validate_examples_in_tfrecord(self, num_sampled_examples):
      input_examples = [
          # This example is anomalous because its feature contains a value that is
          # not in the string_domain specified in the schema.
          """
            features {
                feature {
                  key: 'annotated_enum'
                  value { bytes_list { value: [ 'D' ] } }
                }
            }
          """,
          # This example is anomalous because it contains a feature that is not
          # in the schema.
          """
            features {
                feature {
                  key: 'annotated_enum'
                  value { bytes_list { value: [ 'A' ] } }
                }
                feature {
                  key: 'unknown_feature'
                  value { bytes_list { value: [ 'A' ] } }
                }
            }
          """,
      ]
      schema = text_format.Parse(
          """
                string_domain {
                  name: "MyAloneEnum"
                  value: "A"
                  value: "B"
                  value: "C"
                }
                feature {
                  name: "annotated_enum"
                  value_count {
                    min:1
                    max:1
                  }
                  presence {
                    min_count: 1
                  }
                  type: BYTES
                  domain: "MyAloneEnum"
                }
                """,
          schema_pb2.Schema(),
      )
      options = stats_options.StatsOptions(
          schema=schema,
          num_top_values=2,
          num_rank_histogram_buckets=2,
          num_values_histogram_buckets=2,
          num_histogram_buckets=2,
          num_quantiles_histogram_buckets=2,
      )
  
      temp_dir_path = self.create_tempdir().full_path
      input_data_path = os.path.join(
          temp_dir_path, "input_data.tfrecord"
      )
      with tf.io.TFRecordWriter(input_data_path) as writer:
          for example in input_examples:
              example = text_format.Parse(example, tf.train.Example())
              writer.write(example.SerializeToString())
  
      expected_result = text_format.Parse(
          """
      datasets {
        name: 'annotated_enum_ENUM_TYPE_UNEXPECTED_STRING_VALUES'
        num_examples: 1
        features {
          path: {
            step: 'annotated_enum'
          }
          type: STRING
          string_stats {
            common_stats {
              num_non_missing: 1
              num_missing: 0
              min_num_values: 1
              max_num_values: 1
              avg_num_values: 1.0
              tot_num_values: 1
              num_values_histogram {
                buckets {
                  low_value: 1.0
                  high_value: 1.0
                  sample_count: 0.5
                }
                buckets {
                  low_value: 1.0
                  high_value: 1.0
                  sample_count: 0.5
                }
                type: QUANTILES
              }
            }
            unique: 1
            top_values {
              value: "D"
              frequency: 1.0
            }
            avg_length: 1.0
            rank_histogram {
              buckets {
                label: "D"
                sample_count: 1.0
              }
            }
          }
        }
      }
      datasets {
        name: 'unknown_feature_SCHEMA_NEW_COLUMN'
        num_examples: 1
        features {
          path: {
            step: 'unknown_feature'
          }
          type: STRING
          string_stats {
            common_stats {
              num_non_missing: 1
              num_missing: 0
              min_num_values: 1
              max_num_values: 1
              avg_num_values: 1.0
              tot_num_values: 1
              num_values_histogram {
                buckets {
                  low_value: 1.0
                  high_value: 1.0
                  sample_count: 0.5
                }
                buckets {
                  low_value: 1.0
                  high_value: 1.0
                  sample_count: 0.5
                }
                type: QUANTILES
              }
            }
            unique: 1
            top_values {
              value: "A"
              frequency: 1.0
            }
            avg_length: 1.0
            rank_histogram {
              buckets {
                label: "A"
                sample_count: 1.0
              }
            }
          }
        }
        features {
          path: {
            step: 'annotated_enum'
          }
          type: STRING
          string_stats {
            common_stats {
              num_non_missing: 1
              num_missing: 0
              min_num_values: 1
              max_num_values: 1
              avg_num_values: 1.0
              tot_num_values: 1
              num_values_histogram {
                buckets {
                  low_value: 1.0
                  high_value: 1.0
                  sample_count: 0.5
                }
                buckets {
                  low_value: 1.0
                  high_value: 1.0
                  sample_count: 0.5
                }
                type: QUANTILES
              }
            }
            unique: 1
            top_values {
              value: "A"
              frequency: 1.0
            }
            avg_length: 1.0
            rank_histogram {
              buckets {
                label: "A"
                sample_count: 1.0
              }
            }
          }
        }
      }
      """,
          statistics_pb2.DatasetFeatureStatisticsList(),
      )
  
      actual_result = validation_lib.validate_examples_in_tfrecord(
          data_location=input_data_path,
          stats_options=options,
          num_sampled_examples=num_sampled_examples,
      )
      if num_sampled_examples:
          actual_result, sampled_examples = actual_result
          self.assertCountEqual(
              [
                  (
                      "annotated_enum_ENUM_TYPE_UNEXPECTED_STRING_VALUES",
                      [
                          text_format.Parse(
                              input_examples[0], tf.train.Example()
                          )
                      ],
                  ),
                  (
                      "unknown_feature_SCHEMA_NEW_COLUMN",
                      [
                          text_format.Parse(
                              input_examples[1], tf.train.Example()
                          )
                      ],
                  ),
              ],
              sampled_examples.items(),
          )
      compare_fn = (
          test_util.make_dataset_feature_stats_list_proto_equal_fn(
              self, expected_result
          )
      )
      compare_fn([actual_result])
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  from absl.testing import absltest
  from absl.testing import parameterized
  import pandas
  import tensorflow
  from tensorflow_data_validation.statistics import stats_options
  from tensorflow_data_validation.utils import test_util
  from tensorflow_data_validation.utils import validation_lib
  from google.protobuf import text_format
  from tensorflow_metadata.proto.v0 import schema_pb2
  from tensorflow_metadata.proto.v0 import statistics_pb2
label_desc: Use image node_id 1 for calling the ValidationLibTest obj's underlying member method code with example usage: obj.test_validate_examples_in_tfrecord(num_sampled_examples) without return types