code: def read_shard_sorted_tfrecords(
      path, key, proto=None, max_records=None, compression_type=None
  ):
      """Yields the parsed records in a TFRecord file path in sorted order.
  
      The input TFRecord file must have each shard already in sorted order when
      using the key function for comparison (but elements can be interleaved across
      shards). Under those constraints, the elements will be yielded in a global
      sorted order.
  
      Args:
        path: String. A path to a TFRecord-formatted file containing protos.
        key: Callable. A function that takes as input a single instance of the proto
          class and returns a value on which the comparison for sorted ordering is
          performed.
        proto: A proto class. proto.FromString() will be called on each serialized
          record in path to parse it.
        max_records: int >= 0 or None. Maximum number of records to read from path.
          If None, the default, all records will be read.
        compression_type: 'GZIP', 'ZLIB', '' (uncompressed), or None to autodetect
          based on file extension.
  
      Yields:
        proto.FromString() values on each record in path in sorted order.
      """
      paths = expanded_paths_if_sharded(path)
  
      keyed_iterables = []
      for path in paths:
          protos = Reader(
              path, proto, compression_type=compression_type
          ).iterate()
          keyed_iterables.append(((key(elem), elem) for elem in protos))
  
      for i, (_, value) in enumerate(heapq.merge(*keyed_iterables)):
          if max_records is not None and i >= max_records:
              return
          yield value
  
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 5 for calling a global function with example usage: read_shard_sorted_tfrecords(path, key, proto, max_records, compression_type) without return types