def get_type_specs_from_feature_specs(
    feature_specs: Dict[str, common_types.FeatureSpecType],
    ragged_sequence_features: FrozenSet[str] = frozenset(),
) -> Dict[str, tf.TypeSpec]:
  """Returns `tf.TypeSpec`s for the given feature specs.

  Returns a dictionary of type_spec with the same type and shape as defined by
  `feature_specs`.

  Args:
    feature_specs: A TensorFlow feature spec.
    ragged_sequence_features: Set of names of features representing ragged
      sequence tensors.

  Returns:
    A dictionary from strings to `tf.TensorSpec`, `tf.SparseTensorSpec` or
    `tf.RaggedTensorSpec`s.

  Raises:
    ValueError: If the feature spec contains feature types not supported.
  """
  result = {}
  for name, feature_spec in feature_specs.items():
    if isinstance(feature_spec, tf.io.FixedLenFeature):
      result[name] = tf.TensorSpec([None] + list(feature_spec.shape),
                                   feature_spec.dtype)
    elif isinstance(feature_spec, tf.io.VarLenFeature):
      result[name] = tf.SparseTensorSpec([None, None], feature_spec.dtype)
    elif isinstance(feature_spec, tf.io.SparseFeature):
      shape = [None] + [None if dim == -1 else dim for dim in feature_spec.size]
      result[name] = tf.SparseTensorSpec(shape, feature_spec.dtype)
    elif isinstance(feature_spec, tf.io.RaggedFeature):
      # Number of dimensions is number of partitions + 1 + 1 batch dimension.
      shape = [None, None]
      ragged_rank = 1
      # Ragged sequence tensors will have additional sequence dimension.
      if name in ragged_sequence_features:
        shape.append(None)
        ragged_rank += 1
      for partition in feature_spec.partitions:
        if isinstance(partition, tf.io.RaggedFeature.UniformRowLength):  # pytype: disable=attribute-error
          shape.append(partition.length)
        else:
          shape.append(None)
          ragged_rank += 1
      result[name] = tf.RaggedTensorSpec(
          shape=shape,
          dtype=feature_spec.dtype,
          ragged_rank=ragged_rank,
          row_splits_dtype=feature_spec.row_splits_dtype)
    else:
      raise ValueError('Invalid feature spec {}.'.format(feature_spec))
  return result
Returns `tf.TypeSpec`s for the given feature specs.

  Returns a dictionary of type_spec with the same type and shape as defined by
  `feature_specs`.

  Args:
    feature_specs: A TensorFlow feature spec.
    ragged_sequence_features: Set of names of features representing ragged
      sequence tensors.

  Returns:
    A dictionary from strings to `tf.TensorSpec`, `tf.SparseTensorSpec` or
    `tf.RaggedTensorSpec`s.

  Raises:
    ValueError: If the feature spec contains feature types not supported.
  
tensorflow_transform/impl_helper.py