class_docstr: Samples rows from record batches.
  
  The record batches in the partition can vary in the number of rows.
  SamplePartition guarantees that the sample returned is always going to be
  <= sample_size.
  
  The actual sampling occurs in `compact`. It uses np.partition to calculate
  the top-k of record batch's rows. Where the top-k is a random number assigned
  to each row. Given a uniform distribution of the random number, we can keep a
  running sample of the partition of size k. This gives each row an equal
  probability of being selected.
class_docstr_tok: ["Samples","rows","from","record","batches",".","The","record","batches","in","the","partition","can","vary","in","the","number","of","rows",".","SamplePartition","guarantees","that","the","sample","returned","is","always","going","to","be","<","=","sample_size",".","The","actual","sampling","occurs","in","`","compact","`",".","It","uses","np.partition","to","calculate","the","top-k","of","record","batch","'s","rows",".","Where","the","top-k","is","a","random","number","assigned","to","each","row",".","Given","a","uniform","distribution","of","the","random","number",",","we","can","keep","a","running","sample","of","the","partition","of","size","k.","This","gives","each","row","an","equal","probability","of","being","selected","."]
docstr: Returns the sample as a record batch.
docstr_tok: ["Returns","the","sample","as","a","record","batch","."]
code: def extract_output(
      self, accumulator: _SampleRecordBatchRowsAccumulator
  ) -> pa.RecordBatch:
      """Returns the sample as a record batch."""
      # We force the compact, to comply with the contract of outputting one record
      # batch.
      acc = self._compact_impl(accumulator)
      assert len(acc.record_batches) == 1
      return acc.record_batches[0]
  
imports: import collections
  import functools
  from typing import Dict, Iterable, Text, Tuple
  import apache_beam
  import numpy
  import pyarrow
  from tensorflow_data_validation import constants
  from tensorflow_data_validation import types
  from tensorflow_data_validation.statistics.generators import stats_generator
  from tensorflow_data_validation.utils import stats_util
  from tfx_bsl.arrow import table_util
  from tensorflow_metadata.proto.v0 import statistics_pb2
label_desc: Use image node_id 6 for calling the _SampleRecordBatchRows obj's underlying member method code with example usage: obj.extract_output(accumulator) and returns: acc