def _batched_placeholder_from_feature_spec(name, feature_spec):
  """Creates a batched placeholder from a feature spec."""
  scope_name = _sanitize_scope_name(name)
  if isinstance(feature_spec, tf.io.FixedLenFeature):
    return tf.compat.v1.placeholder(
        feature_spec.dtype, [None] + feature_spec.shape, name=scope_name)
  elif isinstance(feature_spec, tf.io.VarLenFeature):
    return tf.compat.v1.sparse_placeholder(
        feature_spec.dtype, [None, None], name=scope_name)
  elif isinstance(feature_spec, tf.io.SparseFeature):
    shape = [None] + feature_spec.size if isinstance(
        feature_spec.size, list) else [None, feature_spec.size]
    return tf.compat.v1.sparse_placeholder(
        feature_spec.dtype, shape, name=scope_name)

  raise ValueError('Unsupported feature spec: {}({}) for feature {}'.format(
      feature_spec, type(feature_spec), name))
Creates a batched placeholder from a feature spec.
tensorflow_transform/impl_helper.py