def make_tensor_to_arrow_converter(
    schema: schema_pb2.Schema) -> tensor_to_arrow.TensorsToRecordBatchConverter:
  """Constructs a `tf.Tensor` to `pa.RecordBatch` converter."""
  # Ragged sequence features will have an additional (sequence) dimension that
  # doesn't come from feature partition. Hence, we need to generate type spec
  # accordingly.
  ragged_sequence_features = set()
  feature_specs = schema_utils.schema_as_feature_spec(schema).feature_spec
  for feature in schema.feature:
    if feature.type == schema_pb2.FeatureType.STRUCT:
      for child_feature in feature.struct_domain.feature:
        ragged_sequence_features.add(child_feature.name)
  type_specs = get_type_specs_from_feature_specs(
      feature_specs, frozenset(ragged_sequence_features)
  )

  # Make sure that SparseFeatures are handled as generic SparseTensors as
  # opposed to VarLenSparse. Note that at this point only sparse outputs with
  # rank >2 are inferred as SparseFeatures, but this is likely to change.
  sparse_tensor_names = set()
  for name, spec in feature_specs.items():
    if isinstance(spec, tf.io.SparseFeature):
      sparse_tensor_names.add(name)
  options = tensor_to_arrow.TensorsToRecordBatchConverter.Options(
      sparse_tensor_value_column_name_template=schema_inference
      .SPARSE_VALUES_NAME_TEMPLATE,
      sparse_tensor_index_column_name_template=schema_inference
      .SPARSE_INDICES_NAME_TEMPLATE,
      generic_sparse_tensor_names=frozenset(sparse_tensor_names))
  return tensor_to_arrow.TensorsToRecordBatchConverter(type_specs, options)
Constructs a `tf.Tensor` to `pa.RecordBatch` converter.
tensorflow_transform/impl_helper.py