docstr: Stores records as tfrecord in a fixed number of shards with shuffling.
docstr_tok: ["Stores","records","as","tfrecord","in","a","fixed","number","of","shards","with","shuffling","."]
code: def test_write_tfrecord(self):
      """Stores records as tfrecord in a fixed number of shards with shuffling."""
      path = os.path.join(self.tmp_dir, "foo-train.tfrecord")
      shards_length, total_size = self._write(
          to_write=self.RECORDS_TO_WRITE
      )
      self.assertEqual(self.NUM_SHARDS, len(shards_length))
      self.assertEqual(
          shards_length, [len(shard) for shard in self.SHARDS_CONTENT]
      )
      self.assertEqual(total_size, 10)
      written_files, all_recs = _read_records(path)
      written_index_files, all_indices = _read_indices(path)
      self.assertEqual(
          written_files,
          [
              f"foo-train.tfrecord-{i:05d}-of-{self.NUM_SHARDS:05d}"
              for i in range(self.NUM_SHARDS)
              if shards_length[i]
          ],
      )
      self.assertEqual(all_recs, self.SHARDS_CONTENT)
      self.assertEmpty(written_index_files)
      self.assertEmpty(all_indices)
  
imports: import json
  import os
  from typing import Optional
  from unittest import mock
  from etils import epath
  import tensorflow
  from tensorflow_datasets import testing
  from tensorflow_datasets.core import dataset_utils
  from tensorflow_datasets.core import example_parser
  from tensorflow_datasets.core import file_adapters
  from tensorflow_datasets.core import lazy_imports_lib
  from tensorflow_datasets.core import naming
  from tensorflow_datasets.core import writer
  from tensorflow_datasets.core.utils import shard_utils
  from tensorflow_datasets.core.writer import _ShardSpec
label_desc: Use image node_id 2 for calling the TfrecordsWriterBeamTest obj's underlying member method code with example usage: obj.test_write_tfrecord() without return types