def construct_and_lookup_table(construct_table_callable: Callable[
    [_AssetFileType], lookup_ops.LookupInterface],
                               asset_filepath: _AssetFileType,
                               x: tf.Tensor) -> Tuple[tf.Tensor, tf.Tensor]:
  """Construct a table and look x up in it.

  Args:
    construct_table_callable: A Callable that takes a path to an asset file and
      constructs a lookup table.
    asset_filepath: Path to an asset used to construct the table. Can be a
      python string, a `tf.Tensor`, a `tf.Placeholder`.
    x: A categorical `Tensor` of type tf.string or tf.int[8|16|32|64] to which
      the table lookup should be applied.

  Returns:
    A tuple of the result from looking x up in a table and the table's size.

  """
  # If table is lifted into an initialization scope, add a control dependency
  # on the graph tensor used to track this analyzer in
  # `analyzer_nodes.TENSOR_REPLACEMENTS`.
  asset_filepath, control_dependency = (
      _get_asset_analyzer_output_and_control_dependency(asset_filepath))
  with contextlib.ExitStack() as stack:
    if (tf.inside_function() and
        isinstance(asset_filepath, (ops.EagerTensor, str))):
      # Lift the table initialization out of graph construction to avoid
      # repeated initialization in TF2.
      stack.enter_context(tf.init_scope())

    table = construct_table_callable(asset_filepath)
    table_size = table.size()
  return _lookup_table(table, x, control_dependency), table_size
Construct a table and look x up in it.

  Args:
    construct_table_callable: A Callable that takes a path to an asset file and
      constructs a lookup table.
    asset_filepath: Path to an asset used to construct the table. Can be a
      python string, a `tf.Tensor`, a `tf.Placeholder`.
    x: A categorical `Tensor` of type tf.string or tf.int[8|16|32|64] to which
      the table lookup should be applied.

  Returns:
    A tuple of the result from looking x up in a table and the table's size.

  
tensorflow_transform/tf_utils.py