class_docstr: A Splitter that can be composed with other splitters.
  
  This Splitter writes to the riegeli file format.
  
  See README for details.
class_docstr_tok: ["A","Splitter","that","can","be","composed","with","other","splitters",".","This","Splitter","writes","to","the","riegeli","file","format",".","See","README","for","details","."]
docstr: Serializes a proto to disk.
  
  The writer writes all chunks into a riegeli file. The chunk metadata
  (ChunkMetadata) is written at the very end.
  
  Args:
    file_prefix: string prefix of the filepath. The writer will automatically
      attach a `.pb` or `.cpb` (chunked pb) suffix depending on whether the
      proto is split.
  
  Returns:
    The actual filepath the proto is written to. The filepath will be
    different depending on whether the proto is split, i.e., whether it will
    be a pb or not.
docstr_tok: ["Serializes","a","proto","to","disk",".","The","writer","writes","all","chunks","into","a","riegeli","file",".","The","chunk","metadata","(","ChunkMetadata",")","is","written","at","the","very","end",".","Args",":","file_prefix",":","string","prefix","of","the","filepath",".","The","writer","will","automatically","attach","a","`",".pb","`","or","`",".cpb","`","(","chunked","pb",")","suffix","depending","on","whether","the","proto","is","split",".","Returns",":","The","actual","filepath","the","proto","is","written","to",".","The","filepath","will","be","different","depending","on","whether","the","proto","is","split",",","i.e.",",","whether","it","will","be","a","pb","or","not","."]
code: def write(self, file_prefix: str) -> str:
      """Serializes a proto to disk.
  
      The writer writes all chunks into a riegeli file. The chunk metadata
      (ChunkMetadata) is written at the very end.
  
      Args:
        file_prefix: string prefix of the filepath. The writer will automatically
          attach a `.pb` or `.cpb` (chunked pb) suffix depending on whether the
          proto is split.
  
      Returns:
        The actual filepath the proto is written to. The filepath will be
        different depending on whether the proto is split, i.e., whether it will
        be a pb or not.
      """
      if self._parent_splitter is not None:
          raise ValueError(
              "A child ComposableSplitter's `write` method should not be called "
              "directly, since it inherits unrelated chunks from a parent object. "
              "Please call the parent's `write()` method instead."
          )
  
      start_time = time.time()
      chunks, chunked_message = self.split()
  
      if not chunked_message.chunked_fields:
          path = f"{file_prefix}.pb"
          file_io.atomic_write_string_to_file(
              path, self._proto.SerializeToString(deterministic=True)
          )
          logging.info("Unchunked file exported to %s", path)
          return path
  
      path = f"{file_prefix}.cpb"
      with riegeli.RecordWriter(file_io.FileIO(path, "wb")) as f:
          metadata = chunk_pb2.ChunkMetadata(
              message=chunked_message, version=self.version_def
          )
          for chunk in chunks:
              if isinstance(chunk, message.Message):
                  f.write_message(chunk)
                  chunk_type = chunk_pb2.ChunkInfo.Type.MESSAGE
                  size = chunk.ByteSize()
              else:
                  f.write_record(chunk)
                  chunk_type = chunk_pb2.ChunkInfo.Type.BYTES
                  size = len(chunk)
              metadata.chunks.add(
                  type=chunk_type, size=size, offset=f.last_pos.numeric
              )
          f.write_message(metadata)
  
      end = time.time()
  
      logging.info("Chunked file exported to %s", path)
      logging.info(
          "Total time spent splitting and writing the message: %s",
          end - start_time,
      )
      logging.info(
          "Number of chunks created (including initial message): %s",
          len(chunks),
      )
      return path
  
imports: import abc
  from collections.abc import Sequence
  import time
  from typing import Optional, Union
  from absl import logging
  import riegeli
  from google.protobuf import message
  from tensorflow.python.lib.io import file_io
  from tensorflow.tools.proto_splitter import chunk_pb2
  from tensorflow.tools.proto_splitter import util
  from tensorflow.tools.proto_splitter import version
  from tensorflow.tools.proto_splitter import versions_pb2
label_desc: Use image node_id 5 for calling the ComposableSplitter obj's underlying member method code with example usage: obj.write(file_prefix) and returns: path, path