code: def _write_tfexamples_to_tfrecords(self, examples, compression_type):
      filename = "input_data.tfrecord"
      if (
          compression_type
          == tf.compat.v1.python_io.TFRecordCompressionType.GZIP
      ):
          filename += ".gz"
      data_location = os.path.join(self._get_temp_dir(), filename)
      with tf.io.TFRecordWriter(
          data_location, options=compression_type
      ) as writer:
          for example in examples:
              writer.write(example.SerializeToString())
      return data_location
  
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 4 for calling the StatsGenTest obj's underlying member method code with example usage: obj._write_tfexamples_to_tfrecords(examples, compression_type) and returns: data_location