code: def run_tf_record_benchmark_from_data_source(
      data_source,
      batch_size,
      benchmark,
      file_parallelism=None,
      shuffle_buffer_size=0,
      rounds=100,
  ):
      with TFRecordWriter() as writer:
          dir_path = writer.write(data_source)
          pattern = os.path.join(dir_path, f"*.{writer.extension}")
          filenames = tf.data.Dataset.list_files(pattern)
          parse_function = writer.create_tf_example_parser_fn(
              data_source, with_batch=True
          )
          dataset = create_tf_record_dataset(
              filenames,
              parse_function,
              batch_size,
              file_parallelism=file_parallelism,
              shuffle_buffer_size=shuffle_buffer_size,
          )
          count = benchmark.pedantic(
              target=benchmark_func,
              args=[dataset],
              iterations=2,
              # pytest-benchmark calculates statistic across rounds. Set it with
              # larger number (N > 30) for test statistic.
              rounds=rounds,
              kwargs={},
          )
          assert (
              count > 0
          ), f"TF record count: {count} must be greater than 0"
  
file_path: io/tests/test_atds_avro/utils/benchmark_utils.py
imports: import os
  import tensorflow
  from tests.test_atds_avro.utils.data_source_registry import get_canonical_name, get_data_source_from_registry
  from tests.test_atds_avro.utils.generator.tensor_generator import IntTensorGenerator, FloatTensorGenerator, BoolTensorGenerator
  from tests.test_atds_avro.utils.generator.sparse_tensor_generator import IntSparseTensorGenerator, ValueDistribution
  from tests.test_atds_avro.utils.generator.varlen_tensor_generator import WordVarLenTensorGenerator, DimensionDistribution
  from tests.test_atds_avro.utils.tf_record_writer import TFRecordWriter
label_desc: Use image node_id 4 for calling a global function with example usage: run_tf_record_benchmark_from_data_source(data_source, batch_size, benchmark, file_parallelism, shuffle_buffer_size, rounds) without return types