# Path: tensorflow_transform/common_types.py
# def is_ragged_feature_available() -> bool:
# def is_ragged_feature(spec: FeatureSpecType) -> bool:
# 
# Path: tensorflow_transform/tf_metadata/schema_utils_legacy.py
# def should_set_generate_legacy_feature_spec(feature_spec):
# def set_generate_legacy_feature_spec(schema_proto, value):
# def get_generate_legacy_feature_spec(schema_proto):
# def check_for_unsupported_features(schema_proto):
# def get_deprecated(feature):


import typing
import tensorflow as tf
from typing import Dict, List, Mapping, Optional, Tuple
from tensorflow_transform import common_types
from tensorflow_transform.tf_metadata import schema_utils_legacy
from tfx_bsl.tfxio import tensor_representation_util
from tfx_bsl.types import tfx_namedtuple
from tensorflow_metadata.proto.v0 import path_pb2
from tensorflow_metadata.proto.v0 import schema_pb2


def schema_from_feature_spec(
    feature_spec: Mapping[str, common_types.FeatureSpecType],
    domains: Optional[Mapping[str, common_types.DomainType]] = None
) -> schema_pb2.Schema:
  """Convert a feature spec to a Schema proto.

  Args:
    feature_spec: A TensorFlow feature spec
    domains: (optional) a dict whose keys are feature names and values are one
      of schema_pb2.IntDomain, schema_pb2.StringDomain or
      schema_pb2.FloatDomain.

  Returns:
    A Schema proto

  Raises:
    ValueError: If the feature spec cannot be converted to a Schema proto.
  """
  if domains is None:
    domains = {}

  result = schema_pb2.Schema()

  # Some feature specs can only be represented with the legacy schema, in
  # particular feature specs where any FixedLenFeature has default_value set.
  # We represent these (and only these) using a schema with
  # generate_legacy_feature_spec=True.  Note the generate_legacy_feature_spec
  # field is not part of the open source codebase.

# Path: tensorflow_transform/common_types.py
# def is_ragged_feature_available() -> bool:
# def is_ragged_feature(spec: FeatureSpecType) -> bool:
# 
# Path: tensorflow_transform/tf_metadata/schema_utils_legacy.py
# def should_set_generate_legacy_feature_spec(feature_spec):
# def set_generate_legacy_feature_spec(schema_proto, value):
# def get_generate_legacy_feature_spec(schema_proto):
# def check_for_unsupported_features(schema_proto):
# def get_deprecated(feature):


# Path: tensorflow_transform/tf_metadata/schema_utils.py
import typing
import tensorflow as tf
from typing import Dict, List, Mapping, Optional, Tuple
from tensorflow_transform import common_types
from tensorflow_transform.tf_metadata import schema_utils_legacy
from tfx_bsl.tfxio import tensor_representation_util
from tfx_bsl.types import tfx_namedtuple
from tensorflow_metadata.proto.v0 import path_pb2
from tensorflow_metadata.proto.v0 import schema_pb2



def schema_from_feature_spec(
    feature_spec: Mapping[str, common_types.FeatureSpecType],
    domains: Optional[Mapping[str, common_types.DomainType]] = None
) -> schema_pb2.Schema:
  """Convert a feature spec to a Schema proto.

  Args:
    feature_spec: A TensorFlow feature spec
    domains: (optional) a dict whose keys are feature names and values are one
      of schema_pb2.IntDomain, schema_pb2.StringDomain or
      schema_pb2.FloatDomain.

  Returns:
    A Schema proto

  Raises:
    ValueError: If the feature spec cannot be converted to a Schema proto.
  """
  if domains is None:
    domains = {}

  result = schema_pb2.Schema()

  # Some feature specs can only be represented with the legacy schema, in
  # particular feature specs where any FixedLenFeature has default_value set.
  # We represent these (and only these) using a schema with
  # generate_legacy_feature_spec=True.  Note the generate_legacy_feature_spec
  # field is not part of the open source codebase.

  if schema_utils_legacy.should_set_generate_legacy_feature_spec(feature_spec):