class_docstr: Class to write a TFDS dataset sequentially.
  
  The SequentialWriter can be used to generate TFDS datasets by directly
  appending TF Examples to the desired splits.
  
  Once the user creates a SequentialWriter with a given DatasetInfo, they can
  create splits, append examples to them, and close them whenever they are
  finished.
  
  Note that:
  * Not closing a split may cause data to be lost.
  * The examples are written to disk in the same order that they are given to
    the writer.
  * Since the SequentialWriter doesn't know how many examples are going to be
    written, it can't estimate the optimal number of shards per split. Use the
    `max_examples_per_shard` parameter in the constructor to control how many
    elements there should be per shard.
  
  The datasets written with this writer can be read directly with
  `tfds.builder_from_directories`.
  
  Example:
  
  writer = SequentialWriter(ds_info=ds_info, max_examples_per_shard=1000)
  writer.initialize_splits(['train', 'test'])
  
  while (...):
    # Code that generates the examples
    writer.add_examples({'train': [example1, example2],
                         'test':  [example3]})
    ...
  
  writer.close_splits()
docstr: Adds examples to the splits.
  
  Args:
    split_examples: dictionary of `split_name`:list_of_examples that includes
      the list of examples that has to be added to each of the splits. Not all
      the existing splits have to be in the dictionary
  
  Raises:
    KeyError: if any of the splits doesn't exist.
docstr_tok: ["Adds","examples","to","the","splits",".","Args",":","split_examples",":","dictionary","of","`","split_name","`",":","list_of_examples","that","includes","the","list","of","examples","that","has","to","be","added","to","each","of","the","splits",".","Not","all","the","existing","splits","have","to","be","in","the","dictionary","Raises",":","KeyError",":","if","any","of","the","splits","does","n't","exist","."]
code: def add_examples(self, split_examples: Dict[str, List[Any]]) -> None:
      """Adds examples to the splits.
  
      Args:
        split_examples: dictionary of `split_name`:list_of_examples that includes
          the list of examples that has to be added to each of the splits. Not all
          the existing splits have to be in the dictionary
  
      Raises:
        KeyError: if any of the splits doesn't exist.
      """
      # Write the example and update the shard
      for split_name, examples in split_examples.items():
          split = self._splits.get(split_name, None)
          if not split:
              raise KeyError(f"Split {split} was not initialized.")
          for example in examples:
              serialized_example = _serialize_example(
                  example, self._ds_info.features, self._serializer
              )
              split.add_example(serialized_example)
              if (
                  split.current_shard.num_examples
                  >= self._max_examples_per_shard
              ):
                  split.close_shard()
      self._write_splits_metadata()
  
imports: from __future__ import annotations
  import dataclasses
  import os
  from typing import Any, Dict, List, Optional
  from tensorflow_datasets.core import dataset_info
  from tensorflow_datasets.core import example_serializer
  from tensorflow_datasets.core import features
  from tensorflow_datasets.core import file_adapters
  from tensorflow_datasets.core import naming
  from tensorflow_datasets.core import splits
  from tensorflow_datasets.core.utils import py_utils
  from tensorflow_datasets.core.utils.lazy_imports_utils import array_record_module
  from tensorflow_datasets.core.utils.lazy_imports_utils import tensorflow
label_desc: Use image node_id 3 for calling the SequentialWriter obj's underlying member method code with example usage: obj.add_examples(split_examples) without return types