code: def test_shard_sorted_tfrecords_max_records(
      self, filename, max_records
  ):
      protos, path = self.write_test_protos(filename)
  
      if max_records is None:
          expected_n = len(protos)
      else:
          expected_n = min(max_records, len(protos))
      # Create our generator of records from read_tfrecords.
      actual = tfrecord.read_shard_sorted_tfrecords(
          path,
          key=lambda x: int(x.name),
          proto=reference_pb2.ContigInfo,
          max_records=max_records,
      )
      self.assertLen(list(actual), expected_n)
  
file_path: deepvariant/third_party/nucleus/io/tfrecord_test.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import types
  from absl.testing import absltest
  from absl.testing import parameterized
  from third_party.nucleus.io import tfrecord
  from third_party.nucleus.protos import reference_pb2
  from third_party.nucleus.testing import test_utils
label_desc: Use image node_id 5 for calling the IOTest obj's underlying member method code with example usage: obj.test_shard_sorted_tfrecords_max_records(filename, max_records) without return types