class_docstr: An Arrow Dataset for reading record batches from an input stream.
  Currently supported input streams are a socket client or stdin.
docstr: Create an ArrowStreamDataset by serving a sequence of Arrow record
  batches in a background thread. This constructor requires pyarrow to
  be installed.
  
  Args:
      record_batch_iter: A sequence or iterator of Arrow record batches
      output_types: Tensor dtypes of the output tensors
      output_shapes: TensorShapes of the output tensors or None to
                      infer partial
      columns: Optional list of column indices to be used, if None all are used
      batch_size: Batch size of output tensors, setting a batch size here
                  will create batched tensors from Arrow memory and can be more
                  efficient than using tf.data.Dataset.batch().
                  NOTE: batch_size does not need to be set if batch_mode='auto'
      batch_mode: Mode of batching, supported strings:
                  "keep_remainder" (default, keeps partial batch data),
                  "drop_remainder" (discard partial batch data),
                  "auto" (size to number of records in Arrow record batch)
      record_batch_iter_factory: Optional factory to create additional record
                                  batch iterators for multiple iterations.
docstr_tok: ["Create","an","ArrowStreamDataset","by","serving","a","sequence","of","Arrow","record","batches","in","a","background","thread",".","This","constructor","requires","pyarrow","to","be","installed",".","Args",":","record_batch_iter",":","A","sequence","or","iterator","of","Arrow","record","batches","output_types",":","Tensor","dtypes","of","the","output","tensors","output_shapes",":","TensorShapes","of","the","output","tensors","or","None","to","infer","partial","columns",":","Optional","list","of","column","indices","to","be","used",",","if","None","all","are","used","batch_size",":","Batch","size","of","output","tensors",",","setting","a","batch","size","here","will","create","batched","tensors","from","Arrow","memory","and","can","be","more","efficient","than","using","tf.data.Dataset.batch","(",")",".","NOTE",":","batch_size","does","not","need","to","be","set","if","batch_mode='auto'","batch_mode",":","Mode","of","batching",",","supported","strings",":","``","keep_remainder","''","(","default",",","keeps","partial","batch","data",")",",","``","drop_remainder","''","(","discard","partial","batch","data",")",",","``","auto","''","(","size","to","number","of","records","in","Arrow","record","batch",")","record_batch_iter_factory",":","Optional","factory","to","create","additional","record","batch","iterators","for","multiple","iterations","."]
code: def from_record_batches(
      cls,
      record_batch_iter,
      output_types,
      output_shapes=None,
      columns=None,
      batch_size=None,
      batch_mode="keep_remainder",
      record_batch_iter_factory=None,
  ):
      """Create an ArrowStreamDataset by serving a sequence of Arrow record
      batches in a background thread. This constructor requires pyarrow to
      be installed.
  
      Args:
          record_batch_iter: A sequence or iterator of Arrow record batches
          output_types: Tensor dtypes of the output tensors
          output_shapes: TensorShapes of the output tensors or None to
                          infer partial
          columns: Optional list of column indices to be used, if None all are used
          batch_size: Batch size of output tensors, setting a batch size here
                      will create batched tensors from Arrow memory and can be more
                      efficient than using tf.data.Dataset.batch().
                      NOTE: batch_size does not need to be set if batch_mode='auto'
          batch_mode: Mode of batching, supported strings:
                      "keep_remainder" (default, keeps partial batch data),
                      "drop_remainder" (discard partial batch data),
                      "auto" (size to number of records in Arrow record batch)
          record_batch_iter_factory: Optional factory to create additional record
                                      batch iterators for multiple iterations.
      """
      import pyarrow as pa  # pylint: disable=import-outside-toplevel
  
      # Create a UDS server by default if not Windows
      if os.name != "nt":
          sock_path = os.path.join(
              tempfile.gettempdir(), "arrow_io_stream.sock"
          )
          endpoint = f"unix://{sock_path}"
          try:
              os.unlink(sock_path)
          except OSError:
              if os.path.exists(sock_path):
                  raise
          sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
          sock.bind(sock_path)
      # Create a TCP server
      else:
          sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
          sock.bind(("127.0.0.1", 0))
          host_addr, port = sock.getsockname()
          endpoint = f"{host_addr}:{port}"
      sock.listen(1)
  
      def run_server():
          """serve record batches"""
          curr_iter = record_batch_iter
          while True:
              conn, _ = sock.accept()
              outfile = conn.makefile(mode="wb")
              writer = None
              try:
                  for batch in curr_iter:
                      if writer is None:
                          writer = pa.RecordBatchStreamWriter(
                              outfile, batch.schema
                          )
                      writer.write_batch(batch)
                  if record_batch_iter_factory is not None:
                      curr_iter = record_batch_iter_factory()
              finally:
                  if writer is not None:
                      writer.close()
                  outfile.close()
                  conn.close()
          sock.close()
  
      # Run the server in a thread
      server = threading.Thread(target=run_server)
      server.daemon = True
      server.start()
  
      if columns is None:
          columns = list(range(len(output_types)))
  
      return cls(
          endpoint,
          columns,
          output_types,
          output_shapes,
          batch_size,
          batch_mode,
      )
  
imports: from functools import partial
  import io
  from itertools import chain
  import os
  import socket
  import threading
  import tempfile
  import tensorflow
  from tensorflow import dtypes
  from tensorflow.python.data.ops import dataset_ops
  from tensorflow.python.data.util import structure
  from tensorflow_io.python.ops import core_ops
label_desc: Use image node_id 3 for calling the ArrowStreamDataset obj's underlying member method code with example usage: obj.from_record_batches(cls, record_batch_iter, output_types, output_shapes, columns, batch_size, batch_mode, record_batch_iter_factory) and returns: cls