Returns (shard#, (hkey, serialized_example)).
(
self,
key_example: tuple[hashing.HashKey, Example],
)
| 531 | self.__init__(**state) |
| 532 | |
| 533 | def _serialize_example( |
| 534 | self, |
| 535 | key_example: tuple[hashing.HashKey, Example], |
| 536 | ) -> tuple[Any, bytes]: |
| 537 | """Returns (shard#, (hkey, serialized_example)).""" |
| 538 | key, example = key_example |
| 539 | serialized_example = self._serializer.serialize_example(example) |
| 540 | if self._disable_shuffling: |
| 541 | hkey = key |
| 542 | else: |
| 543 | hkey = self._hasher.hash_key(key) |
| 544 | self.inc_counter(name="serialized_examples") |
| 545 | return (hkey, serialized_example) |
| 546 | |
| 547 | def _check_num_examples(self, num_examples: int) -> int: |
| 548 | if num_examples <= 0: |
nothing calls this directly
no test coverage detected