# 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

  else:
    num_samples = tf.size(x) if reduce_instance_dims else tf.shape(x)[0]
    (count_samples, count_pairs, count_triplets, count_quadruplets,
     l1_factors, l2_factors, l3_factors, l4_factors) = _num_terms_and_factors(
         num_samples, x.dtype)
    x_rank_2 = tf.reshape(x, [num_samples, -1])
    dim_1 = tf.shape(x_rank_2)[1]
    initial_moment_values = tf.zeros([dim_1], dtype=x.dtype)
    (unused_current_index, l1_sum, l2_sum, l3_sum, l4_sum, unused_l1_factors,
     unused_l2_factors, unused_l3_factors, unused_l4_factors,
     unused_x_rank_2) = tf.while_loop(
         _condition_l_moments_dense,
         _iteration_l_moments_dense,
         [tf.constant(0, dim_1.dtype)] + [initial_moment_values] * 4 +
         [l1_factors, l2_factors, l3_factors, l4_factors, x_rank_2])
    final_shape = (() if reduce_instance_dims else tf.shape(x)[1:])
    l1 = tf.reshape(l1_sum, final_shape)
    l2 = tf.reshape(l2_sum, final_shape)
    l3 = tf.reshape(l3_sum, final_shape)
    l4 = tf.reshape(l4_sum, final_shape)
    count_l1 = tf.fill(final_shape, count_samples)
    count_l2 = tf.fill(final_shape, count_pairs)
    count_l3 = tf.fill(final_shape, count_triplets)
    count_l4 = tf.fill(final_shape, count_quadruplets)

  return  (count_l1, l1, count_l2, l2, count_l3, l3, count_l4, l4)


def _validate_and_get_dense_value_key_inputs(

# 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


  else:
    num_samples = tf.size(x) if reduce_instance_dims else tf.shape(x)[0]
    (count_samples, count_pairs, count_triplets, count_quadruplets,
     l1_factors, l2_factors, l3_factors, l4_factors) = _num_terms_and_factors(
         num_samples, x.dtype)
    x_rank_2 = tf.reshape(x, [num_samples, -1])
    dim_1 = tf.shape(x_rank_2)[1]
    initial_moment_values = tf.zeros([dim_1], dtype=x.dtype)
    (unused_current_index, l1_sum, l2_sum, l3_sum, l4_sum, unused_l1_factors,
     unused_l2_factors, unused_l3_factors, unused_l4_factors,
     unused_x_rank_2) = tf.while_loop(
         _condition_l_moments_dense,
         _iteration_l_moments_dense,
         [tf.constant(0, dim_1.dtype)] + [initial_moment_values] * 4 +
         [l1_factors, l2_factors, l3_factors, l4_factors, x_rank_2])
    final_shape = (() if reduce_instance_dims else tf.shape(x)[1:])
    l1 = tf.reshape(l1_sum, final_shape)
    l2 = tf.reshape(l2_sum, final_shape)
    l3 = tf.reshape(l3_sum, final_shape)
    l4 = tf.reshape(l4_sum, final_shape)
    count_l1 = tf.fill(final_shape, count_samples)
    count_l2 = tf.fill(final_shape, count_pairs)
    count_l3 = tf.fill(final_shape, count_triplets)
    count_l4 = tf.fill(final_shape, count_quadruplets)

  return  (count_l1, l1, count_l2, l2, count_l3, l3, count_l4, l4)


def _validate_and_get_dense_value_key_inputs(

    x: common_types.TensorType,