code: def test_write_stats_to_tfrecord_and_binary(self):
      stats1 = text_format.Parse(
          """
          datasets {
            name: 'x'
            num_examples: 100
            features: {
               path: {
                  step: "f1"
               }
            }
          }
          """,
          statistics_pb2.DatasetFeatureStatisticsList(),
      )
      stats2 = text_format.Parse(
          """
          datasets {
            name: 'x'
            num_examples: 100
            features: {
               path: {
                  step: "f2"
               }
            }
          }
          """,
          statistics_pb2.DatasetFeatureStatisticsList(),
      )
  
      stats_combined = text_format.Parse(
          """
          datasets {
            name: 'x'
            num_examples: 100
            features: {
               path: {
                  step: "f1"
               }
            }
            features: {
               path: {
                  step: "f2"
               }
            }
          }
          """,
          statistics_pb2.DatasetFeatureStatisticsList(),
      )
  
      output_path_binary = os.path.join(
          self._get_temp_dir(), "stats.pb"
      )
      output_path_prefix = os.path.join(
          self._get_temp_dir(), "stats_shards"
      )
      columnar_path_prefix = os.path.join(
          self._get_temp_dir(), "columnar_outputs"
      )
      with beam.Pipeline() as p:
          _ = (
              p
              | beam.Create([stats1, stats2])
              | stats_api.WriteStatisticsToRecordsAndBinaryFile(
                  output_path_binary,
                  output_path_prefix,
                  columnar_path_prefix,
              )
          )
  
      stats_from_pb = statistics_pb2.DatasetFeatureStatisticsList()
      serialized_stats = io_util.read_file_to_string(
          output_path_binary, binary_mode=True
      )
      stats_from_pb.ParseFromString(serialized_stats)
      self.assertLen(stats_from_pb.datasets, 1)
      test_util.assert_dataset_feature_stats_proto_equal(
          self, stats_from_pb.datasets[0], stats_combined.datasets[0]
      )
  
      stats_from_shards = stats_util.load_sharded_statistics(
          output_path_prefix + "*"
      ).proto()
      self.assertLen(stats_from_shards.datasets, 1)
      test_util.assert_dataset_feature_stats_proto_equal(
          self,
          stats_from_shards.datasets[0],
          stats_combined.datasets[0],
      )
  
      if artifacts_io_impl.get_default_columnar_provider():
          self.assertNotEmpty(
              tf.io.gfile.glob(columnar_path_prefix + "-*-of-*")
          )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  import tempfile
  from absl.testing import absltest
  import apache_beam
  from apache_beam.testing import util
  import numpy
  import pyarrow
  import tensorflow
  from tensorflow_data_validation.api import stats_api
  from tensorflow_data_validation.utils import artifacts_io_impl
  from tensorflow_data_validation.statistics import stats_options
  from tensorflow_data_validation.utils import io_util
  from tensorflow_data_validation.utils import stats_util
  from tensorflow_data_validation.utils import test_util
  from google.protobuf import text_format
  from tensorflow_metadata.proto.v0 import statistics_pb2
label_desc: Use image node_id 9 for calling the StatsAPITest obj's underlying member method code with example usage: obj.test_write_stats_to_tfrecord_and_binary() without return types