code: def test_stats_gen_with_tfrecords_of_tfexamples(
      self, compression_type
  ):
      examples = [
          self._make_example(
              {
                  "a": ("float", [1.0, 2.0]),
                  "b": ("bytes", [b"a", b"b", b"c", b"e"]),
              }
          ),
          self._make_example(
              {
                  "a": ("float", [3.0, 4.0, float("nan"), 5.0]),
                  "b": ("bytes", [b"a", b"c", b"d", b"a"]),
              }
          ),
          self._make_example(
              {
                  "a": ("float", [1.0]),
                  "b": ("bytes", [b"a", b"b", b"c", b"d"]),
              }
          ),
      ]
      tf_compression_lookup = {
          CompressionTypes.AUTO: tf.compat.v1.python_io.TFRecordCompressionType.NONE,
          CompressionTypes.GZIP: tf.compat.v1.python_io.TFRecordCompressionType.GZIP,
      }
      input_data_path = self._write_tfexamples_to_tfrecords(
          examples, tf_compression_lookup[compression_type]
      )
  
      expected_result = text_format.Parse(
          """
      datasets {
        num_examples: 3
        features {
          path {
            step: "a"
          }
          type: FLOAT
          num_stats {
            common_stats {
              num_non_missing: 3
              num_missing: 0
              min_num_values: 1
              max_num_values: 4
              avg_num_values: 2.33333333
              tot_num_values: 7
            }
            mean: 2.66666666
            std_dev: 1.49071198
            num_zeros: 0
            min: 1.0
            max: 5.0
            median: 3.0
          }
        }
        features {
          path {
            step: "b"
          }
          type: STRING
          string_stats {
            common_stats {
              num_non_missing: 3
              min_num_values: 4
              max_num_values: 4
              avg_num_values: 4.0
              tot_num_values: 12
            }
            unique: 5
            top_values {
              value: "a"
              frequency: 4.0
            }
            top_values {
              value: "c"
              frequency: 3.0
            }
            avg_length: 1.0
            rank_histogram {
              buckets {
                low_rank: 0
                high_rank: 0
                label: "a"
                sample_count: 4.0
              }
              buckets {
                low_rank: 1
                high_rank: 1
                label: "c"
                sample_count: 3.0
              }
            }
          }
        }
      }
      """,
          statistics_pb2.DatasetFeatureStatisticsList(),
      )
  
      result = stats_gen_lib.generate_statistics_from_tfrecord(
          data_location=input_data_path,
          stats_options=self._default_stats_options,
      )
      compare_fn = (
          test_util.make_dataset_feature_stats_list_proto_equal_fn(
              self, expected_result, check_histograms=False
          )
      )
      compare_fn([result])
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import gzip
  import os
  import tempfile
  from absl.testing import absltest
  from absl.testing import parameterized
  from apache_beam.io.filesystem import CompressionTypes
  import pandas
  import tensorflow
  from tensorflow_data_validation.statistics import stats_options
  from tensorflow_data_validation.utils import stats_gen_lib
  from tensorflow_data_validation.utils import test_util
  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 5 for calling the StatsGenTest obj's underlying member method code with example usage: obj.test_stats_gen_with_tfrecords_of_tfexamples(compression_type) without return types