code: def write_shard(
      output_filename: str,
      single_record: str,
      num_images_per_shard: int,
  ) -> None:
      # TODO(swang): Make sure it works in cluster setting. Need to either sync
      # all data files to worker nodes using VM launcher's file_mounts or run
      # data script on each node.
      with tf.python_io.TFRecordWriter(output_filename) as writer:
          for _ in range(num_images_per_shard):
              writer.write(single_record)
      print(f"Done writing {output_filename}", file=sys.stderr)
  
imports: from typing import Union, Iterable, Tuple, Optional
  import os
  import requests
  import shutil
  import sys
  import tensorflow.compat.v1
  import time
  from ray.util.scheduling_strategies import NodeAffinitySchedulingStrategy
  import ray
label_desc: Use image node_id 5 for calling a global function with example usage: write_shard(output_filename, single_record, num_images_per_shard) without return types