# Path: tensorflow_transform/annotators.py
# _ASSET_KEY_COLLECTION = 'tft_asset_key_collection'
# _ASSET_FILENAME_COLLECTION = 'tft_asset_filename_collection'
# _OBJECT_TRACKER = None
# VOCABULARY_SIZE_BY_NAME_COLLECTION = 'tft_vocabulary_size_by_name_collection'
#   _OBJECT_TRACKER = object_tracker
#     _OBJECT_TRACKER = None
# class ObjectTracker:
#   def __init__(self):
#   def trackable_objects(self) -> List[base.Trackable]:
#   def add_trackable_object(self, trackable_object: base.Trackable,
#                            name: Optional[str]):
# def object_tracker_scope(object_tracker: ObjectTracker):
# def _get_object(name: str) -> Optional[base.Trackable]:
# def track_object(trackable: base.Trackable, name: Optional[str]):
# def make_and_track_object(trackable_factory_callable: Callable[[],
#                                                                base.Trackable],
#                           name: Optional[str] = None) -> base.Trackable:
# def get_asset_annotations(graph: tf.Graph):
# def clear_asset_annotations(graph: tf.Graph):
# def annotate_asset(asset_key: str, asset_filename: str):
# def annotate_vocab_size(vocab_filename: str, vocab_size: tf.Tensor):
# 
# Path: tensorflow_transform/common_types.py
# def is_ragged_feature_available() -> bool:
# def is_ragged_feature(spec: FeatureSpecType) -> bool:


import contextlib
import enum
import tensorflow as tf
from typing import Callable, Optional, Tuple, Union
from tensorflow_transform import annotators
from tensorflow_transform import common_types
from tfx_bsl.types import tfx_namedtuple
from tensorflow.python.framework import composite_tensor
from tensorflow.python.framework import func_graph
from tensorflow.python.framework import ops
from tensorflow.python.ops import lookup_ops
from tensorflow.python.util import object_identity


# TODO(https://issues.apache.org/jira/browse/SPARK-22674): Switch to
# `collections.namedtuple` or `typing.NamedTuple` once the Spark issue is
# resolved.

# pylint: disable=g-direct-tensorflow-import
# pylint: enable=g-direct-tensorflow-import

_AssetFileType = Union[tf.Tensor, str]

_FLOATING_NAN = float('nan')
# Global sentinels used to keep track of the total counts of y
GLOBAL_Y_COUNT_SENTINEL_STRING = b'global_y_count_sentinel'
GLOBAL_Y_COUNT_SENTINEL_INT = tf.int64.limits[1]

# Key for graph collection containing tuple of a key to the eager tensor
# representing asset path and the graph tensor tracking the analyzer in
# `analyzer_nodes.TENSOR_REPLACEMENTS`.
_ASSET_REPLACEMENTS = 'tft_asset_replacements'

ReducedBatchWeightedCounts = tfx_namedtuple.namedtuple('ReducedBatchCounts', [
    'unique_x', 'summed_weights_per_x', 'summed_positive_per_x_and_y',
    'counts_per_x'
])

_CompositeTensorRef = tfx_namedtuple.namedtuple('_CompositeTensorRef',
                                                ['type_spec', 'list_of_refs'])



# Path: tensorflow_transform/annotators.py
# _ASSET_KEY_COLLECTION = 'tft_asset_key_collection'
# _ASSET_FILENAME_COLLECTION = 'tft_asset_filename_collection'
# _OBJECT_TRACKER = None
# VOCABULARY_SIZE_BY_NAME_COLLECTION = 'tft_vocabulary_size_by_name_collection'
#   _OBJECT_TRACKER = object_tracker
#     _OBJECT_TRACKER = None
# class ObjectTracker:
#   def __init__(self):
#   def trackable_objects(self) -> List[base.Trackable]:
#   def add_trackable_object(self, trackable_object: base.Trackable,
#                            name: Optional[str]):
# def object_tracker_scope(object_tracker: ObjectTracker):
# def _get_object(name: str) -> Optional[base.Trackable]:
# def track_object(trackable: base.Trackable, name: Optional[str]):
# def make_and_track_object(trackable_factory_callable: Callable[[],
#                                                                base.Trackable],
#                           name: Optional[str] = None) -> base.Trackable:
# def get_asset_annotations(graph: tf.Graph):
# def clear_asset_annotations(graph: tf.Graph):
# def annotate_asset(asset_key: str, asset_filename: str):
# def annotate_vocab_size(vocab_filename: str, vocab_size: tf.Tensor):
# 
# Path: tensorflow_transform/common_types.py
# def is_ragged_feature_available() -> bool:
# def is_ragged_feature(spec: FeatureSpecType) -> bool:


# Path: tensorflow_transform/tf_utils.py
import contextlib
import enum
import tensorflow as tf
from typing import Callable, Optional, Tuple, Union
from tensorflow_transform import annotators
from tensorflow_transform import common_types
from tfx_bsl.types import tfx_namedtuple
from tensorflow.python.framework import composite_tensor
from tensorflow.python.framework import func_graph
from tensorflow.python.framework import ops
from tensorflow.python.ops import lookup_ops
from tensorflow.python.util import object_identity



# TODO(https://issues.apache.org/jira/browse/SPARK-22674): Switch to
# `collections.namedtuple` or `typing.NamedTuple` once the Spark issue is
# resolved.

# pylint: disable=g-direct-tensorflow-import
# pylint: enable=g-direct-tensorflow-import

_AssetFileType = Union[tf.Tensor, str]

_FLOATING_NAN = float('nan')
# Global sentinels used to keep track of the total counts of y
GLOBAL_Y_COUNT_SENTINEL_STRING = b'global_y_count_sentinel'
GLOBAL_Y_COUNT_SENTINEL_INT = tf.int64.limits[1]

# Key for graph collection containing tuple of a key to the eager tensor
# representing asset path and the graph tensor tracking the analyzer in
# `analyzer_nodes.TENSOR_REPLACEMENTS`.
_ASSET_REPLACEMENTS = 'tft_asset_replacements'

ReducedBatchWeightedCounts = tfx_namedtuple.namedtuple('ReducedBatchCounts', [
    'unique_x', 'summed_weights_per_x', 'summed_positive_per_x_and_y',
    'counts_per_x'
])

_CompositeTensorRef = tfx_namedtuple.namedtuple('_CompositeTensorRef',
                                                ['type_spec', 'list_of_refs'])



def get_values(x: common_types.TensorType) -> tf.Tensor: