class_docstr: Shuffles and writes Examples to sharded TFRecord files.
  
  The number of shards is computed automatically.
class_docstr_tok: ["Shuffles","and","writes","Examples","to","sharded","TFRecord","files",".","The","number","of","shards","is","computed","automatically","."]
docstr: Writes given Example.
  
  The given example is not directly written to the tfrecord file, but to a
  temporary file (or memory). The finalize() method does write the tfrecord
  files.
  
  Args:
    key (int|bytes): the key associated with the example. Used for shuffling.
    example: the Example to write to the tfrecord file.
docstr_tok: ["Writes","given","Example",".","The","given","example","is","not","directly","written","to","the","tfrecord","file",",","but","to","a","temporary","file","(","or","memory",")",".","The","finalize","(",")","method","does","write","the","tfrecord","files",".","Args",":","key","(","int|bytes",")",":","the","key","associated","with","the","example",".","Used","for","shuffling",".","example",":","the","Example","to","write","to","the","tfrecord","file","."]
code: def write(self, key, example):
      """Writes given Example.
  
      The given example is not directly written to the tfrecord file, but to a
      temporary file (or memory). The finalize() method does write the tfrecord
      files.
  
      Args:
        key (int|bytes): the key associated with the example. Used for shuffling.
        example: the Example to write to the tfrecord file.
      """
      serialized_example = self._serializer.serialize_example(
          example=example
      )
      self._shuffler.add(key, serialized_example)
      self._num_examples += 1
  
imports: import dataclasses
  import functools
  import itertools
  import json
  import os
  from typing import Any, Iterable, List, Optional, Tuple
  from absl import logging
  from etils import epath
  from tensorflow_datasets.core import example_parser
  from tensorflow_datasets.core import example_serializer
  from tensorflow_datasets.core import file_adapters
  from tensorflow_datasets.core import hashing
  from tensorflow_datasets.core import lazy_imports_lib
  from tensorflow_datasets.core import naming
  from tensorflow_datasets.core import shuffle
  from tensorflow_datasets.core import utils
  from tensorflow_datasets.core.utils import file_utils
  from tensorflow_datasets.core.utils import shard_utils
  from tensorflow_datasets.core.utils import type_utils
  from tensorflow_datasets.core.utils.lazy_imports_utils import apache_beam
label_desc: Use image node_id 2 for calling the Writer obj's underlying member method code with example usage: obj.write(key, example) without return types