class_docstr: Information of a split that is being created.
docstr: Adds an example to the shard.
  
  If there is no open shard, it starts a new one.
  
  Args:
    serialized_example: example to add to the shard.
  
  Raises:
    ValueError: if the split is already closed.
docstr_tok: ["Adds","an","example","to","the","shard",".","If","there","is","no","open","shard",",","it","starts","a","new","one",".","Args",":","serialized_example",":","example","to","add","to","the","shard",".","Raises",":","ValueError",":","if","the","split","is","already","closed","."]
code: def add_example(self, serialized_example: str) -> None:
      """Adds an example to the shard.
  
      If there is no open shard, it starts a new one.
  
      Args:
        serialized_example: example to add to the shard.
  
      Raises:
        ValueError: if the split is already closed.
      """
      if self.closed:
          raise ValueError(f"Split {self.info.name} is already closed.")
      if self.current_shard is None:
          if self.info.filename_template is None:
              raise ValueError(
                  f"Split {self.info.name} has no filename template."
              )
          path = self.info.filename_template.sharded_filepath(
              shard_index=self.complete_shards, num_shards=None
          )
          if self.file_format == file_adapters.FileFormat.TFRECORD:
              self.current_shard = Shard(
                  writer=tf.io.TFRecordWriter(os.fspath(path))
              )
          elif (
              self.file_format == file_adapters.FileFormat.ARRAY_RECORD
          ):
              self.current_shard = Shard(
                  writer=array_record_module.ArrayRecordWriter(
                      os.fspath(path), "group_size:1"
                  )
              )
          else:
              raise ValueError(
                  "Unknown file format %s" % self.file_format
              )
      self.current_shard.add_example(serialized_example)
  
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 1 for calling the Split obj's underlying member method code with example usage: obj.add_example(serialized_example) without return types