code: def write_tfrecords(protos, output_path, compression_type=None):
      """Writes protos to output_path.
  
      This function writes serialized strings of each proto in protos to output_path
      in their original order. If output_path is a sharded file (e.g., foo@2), this
      function will write the protos spread out as evenly as possible among the
      individual components of the sharded spec (e.g., foo-00000-of-00002 and
      foo-00001-of-00002). Note that the order of records in the sharded files may
      differ from the order in protos due to the striping.
  
      Args:
        protos: An iterable of protobufs. The objects we want to write out.
        output_path: str. The filepath where we want to write protos.
        compression_type: 'GZIP', 'ZLIB', '' (uncompressed), or None to autodetect
          based on file extension.
      """
      if sharded_file_utils.is_sharded_file_spec(output_path):
          with contextlib2.ExitStack() as stack:
              (
                  _,
                  n_shards,
                  _,
              ) = sharded_file_utils.parse_sharded_file_spec(
                  output_path
              )
              writers = [
                  stack.enter_context(
                      Writer(
                          sharded_file_utils.sharded_filename(
                              output_path, i
                          ),
                          compression_type=compression_type,
                      )
                  )
                  for i in range(n_shards)
              ]
              for i, proto in enumerate(protos):
                  writers[i % n_shards].write(proto)
      else:
          with Writer(
              output_path, compression_type=compression_type
          ) as writer:
              for proto in protos:
                  writer.write(proto)
  
file_path: deepvariant/third_party/nucleus/io/tfrecord.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import heapq
  import contextlib2
  from third_party.nucleus.io import genomics_reader
  from third_party.nucleus.io import genomics_writer
  from third_party.nucleus.io import sharded_file_utils
  from tensorflow.core.example import example_pb2
label_desc: Use image node_id 6 for calling a global function with example usage: write_tfrecords(protos, output_path, compression_type) without return types